I am trying to test an API via AJAX. I have used JQuery:
$(document).ready(function(){
$('#ajax').click(function(e){
var sampleHTML = '<html></html>';
var api_key = 'asfasasfs2';
$.post('http://google.com/', { api_key: api_key, html: sampleHTML },
function(data) {
alert("Data Loaded: " + data);
});
});
});
When ever I use an absolute URL, which I need to as this is an external API, firebug shows me nothing. As if no post request was made!
I thought I would test it on chrome and it shows the status as cancelled and the type as pending. What does this mean?
Please note, I’ve put Google’s URL to hide my API URL.
See the jquery documentation. If the url is not on the same domain, it won’t work:
You could try an ajax post with script or jsonp as the return data if you can adjust your api: