I am trying to call an external Web service via JQuery Ajax in the following format
$.ajax({
url: "<web-service URL>",
cache: false,
success: function(html){
alert( "Called");
}
});
But it throws a 404 error saying page not found.
I modified the Ajax call by replacing the URL with the following
$.ajax({
url: "http://www.google.com",
cache: false,
success: function(html){
alert( "Called");
}
});
But i still got the 404 Error, with the URL String looking something like this
http://localhost:8081/Application/root/www.google.com?_=1329471109853"
Unable to understand as to why is it appending the google.com URL to the localhost
Can anybody tell me what am i doing wrong , all i want to do is to call an external webservice URL in the background.
You need to read about the same-origin-policy. You can only make ajax calls to the same host that the page you are on came from. There are a few ways to work around this (like using JSONP), but you will have to code for and accept the limitations of those work-arounds.