Search code examples
javascriptajaxhttp-postexternalsend

Sending data to an external file via Ajax


When I use this code, it works:

ajax.open("post","a.php",true);

but when I try to send data to a external file like:

ajax.open("post","http://www.example.com/a.php",true);

it doesn't work.

Are there any solution?


Solution

  • The URL of the file that must be opened - the location of the server side script. This can be a absolute URL like(http://www.foo.com/bar.php) or a relative one(/bar.php). A note of caution - this URL should be in the same domain as the script is. You cannot call a script in google.com from a script that is running in yahoo.com. This is a security measure implemented in most browsers to prevent XSS.

    Regards, Cyril