I have a PHP file called ‘myProxy.php’ sitting on my server that looks like this:
<?php
echo "text";
exit();
?>
When I try to get that string from the file with an AJAX call that looks like this:
$.ajax({
url: "http://www.mydomain.com/myProxy.php",
type: "GET",
success: function(data) {
alert("Horray!");
}
});
The script turns absolutely nothing and I get a red error icon in the Firebug console. Does anyone know what might be causing this? Perhaps a setting is not set somewhere?
I have a feeling you’re running into a same origin policy restriction.
For plain old AJAX, your script and resource should exist on the same domain. If this is actually the case, you can simply use
If you truly need cross-domain support, you can change your PHP script to respond to JSONP requests
… and the JavaScript