I'm practicing on AJAX and RESTful Web Services and i got an error on console which says:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ... blah blah blah...
So, my code doesn't run on any browser except Safari! On every other browser like Chrome, Firefor or Opera i got the same error.
As long as i have searched through the internet, i found that the only way to achieve this is to make a proxy server which will send the request to the server and then append some headers on the response back to client.
The www.corsproxy.com solution its great, but i just want to have my own proxy! :-)
My simple jQuery code is:
var dataURL = "http://fou.com/last.json";
$.ajax({
url: dataURL,
async: true,
type: "GET",
dataType: "json",
success: editData
// editData it's a function which gonna edit the data from fou.com ..
})
Which will the php code be according to this?
You can do something like this:
JS:
PHP part at http://myproxy.com :
The PHP part is very simplified to give you an idea.