0

When I use the following code I get a 200 response for the call to "http://api.jquery.com/jquery.ajax/", but the error callback is fired. Please could someone let me know what I am doing wrong. Cheers.

 $.ajax(
   { 
     type: "GET",
     url: "http://api.jquery.com/jquery.ajax/", 
     success: function( data ) {
         $( "#geocodeData" ).html( data );
         },
         error: function(jqXHR, textStatus, errorThrown) 
         {
             alert("error!");
         }
     });

1 Answers1

0

It's because of the 'same origin policy'. Modern browsers doesn't allow you to call to other urls. You will have to use JSONP. See this or this for more details.

Community
  • 1
  • 1
user3719477
  • 110
  • 9