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
  • 70
  • 3
  • 13

3 Answers3

2

Look up the Same Origin Policy and JSONP

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
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
  • 30,619
  • 30
  • 89
  • 138
0

add this to your php files:

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