I'm aware that modern browsers don't allow AJAX requests to foreign URLS, The workaround is JSON encoding and I'm doing that like this:
function findZipCodesInRadius(userZip, radiusInMiles) {
$.getJSON("http://mydomain.com/php/zipCodesInRadius.php?callback=?", {
TheUserZip: userZip,
TheRadiusInMiles: radiusInMiles
},
function (data) {
alert("Data Loaded: " + data);
});
}
and on the PHP side of things I have it "echoing" the results back like this:
$JSONData = array("callback"=>"true");
echo json_encode($JSONData);
After looking around google, the above code is what I've found and it's still not working. How do I properly echo the callback? Maybe I'm doing the ajax request incorrectly? I usually do it a different way, but because I'm trying to access a file on another website of mine, I've been looking everywhere on the proper way of sending the request and this is what I came up with. Not sure what I'm doing wrong.