0

I have a PHP/javascript app that queries and returns info using an ajax request. On every server I've used so far, this works as expected, passing an Ajax GET request to the server and returning json data.

On a new install, the query fails and returns nothing-- I inspected the request and it turns out that rather than passing the query as a GET, the server is passing it as an OPTIONS request. Is there any reason for this? I have no idea why this might happen.

THanks!

user41172
  • 145
  • 2
  • 5

1 Answers1

1

It sounds like you're making a cross-domain AJAX request, which are disallowed by web browsers due to security concerns.

I would create a server-side PHP page that retrieves the remote resource that you're trying to access in your AJAX request, and simply make an AJAX request for that server-side page. The server-side page acts as a proxy between your client-side and your remote resource, which circumvents the web browser's grip on cross-domain client-side requests.

  • Hi Tim-- no, it's all in the same domain. The oddity is that ther server for whatever reason changed the mechanism from a GET to a POST-- the code is well tested and works fine on literally dozens of servers. I'm hoping there's a known reason why a server might change the HTTP request. – user41172 Sep 28 '10 at 16:11
  • it appears that the issue was caused by using www on the URL of the page requested, and no www value for the ajax request URL. – user41172 Sep 28 '10 at 20:14