Reputation: 109
I use document.write()
for json. work in document.write(JSON.stringify({name:'jason',surname:'etc'}));
outside the ajax, but not work in .done()
. I tried remove dataType:'json'
but not work.
$.ajax({
url: "http://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json",
dataType:'json'
})
.done(function(data) {
console.log("success",data);
document.write(JSON.stringify(data));
//document.write(data);
})
.fail(function(data) {
console.log("error",data);
})
.always(function() {
console.log("complete");
});
Upvotes: 0
Views: 1917
Reputation: 9614
If you check your browsers console, you should see the following error ...
jquery-git.js:9648 Mixed Content: The page at 'https://jsfiddle.net/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json'. This request has been blocked; the content must be served over HTTPS.
Change your url to protocol from http
to https
.
https://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json
That should work.
Upvotes: 1
Reputation: 506
Why don't you use jQuery's getJSON?
$.getJSON('https://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json')
.done(function(data) {
console.log("success",data);
document.write(JSON.stringify(data));
//document.write(data);
})
Upvotes: 1