0

Possible Duplicate:
Cross Domain Ajax Request with JQuery/PHP

I hope you can help I have a php page on a subdomain which onclick needs to execute a PHP script on the main domain with a GET request. For some reason

$.get("http://www.domain.com/page", {param: param}, function(data){alert(data);});

Is returning a 404 error. The page is definiately there and will run when the url is entered directed.

Any help would be much appreciated. Thanks Mark

Community
  • 1
  • 1
Mark
  • 72
  • 3
  • 12

3 Answers3

2

Look up the Same Origin Policy and JSONP

Explosion Pills
  • 183,406
  • 48
  • 308
  • 385
0

I believe the problem is that you are trying to load a file directly off of another origin. Browsers prevent this (making you get a 404 error).

You can read about the exact details here:

http://en.wikipedia.org/wiki/Same_origin_policy

Freesnöw
  • 28,081
  • 30
  • 87
  • 133
0

add this to your php files:

header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
Marknl
  • 184
  • 1
  • 9