I have been trying to access data from another site by ajax but failed.
The scenario is if i post data to the site by a form then i am redirected to the site and displays correct data.
What I want to do is I want my script to fetch that data using ajax.
One thing i want to clear that I cant modify the script on the server side so that i can add Access-Control-Allow-Origin header.
Is their any trick or hack so that I get the data???
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'http://somedomain.com/FlightStatus.aspx',
data: {ArrFltStatus:'KDU',DepFltStatus:'ISB',DropDownDay:'today',Submit:'Proceed'},
success: function(data){
alert(data);
},
error:function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("responseText: "+xhr.responseText);
}
});
});
If they have a JSONp interface, use it (that won’t work with POST though).
Otherwise you need proxy script on your server which performs the remote access so your JavaScript can access a resource on the same domain.