Javascript jquery ajax中的JSON.stringify

Javascript jquery ajax中的JSON.stringify,javascript,jquery,json,ajax,Javascript,Jquery,Json,Ajax,我对json使用document.write()。在document.write(JSON.stringify({name:'jason',姓氏:'etc'))中工作在ajax之外,但不能在.done()中工作。我尝试删除数据类型:'json',但不起作用 $.ajax({ url: "http://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json

我对json使用
document.write()
。在
document.write(JSON.stringify({name:'jason',姓氏:'etc'))中工作在ajax之外,但不能在
.done()
中工作。我尝试删除
数据类型:'json'
,但不起作用

$.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");
});

如果您检查浏览器控制台,您应该会看到以下错误

jquery git.js:9648混合内容:页面位于'https://jsfiddle.net/'已通过HTTPS加载,但请求了不安全的XMLHttpRequest终结点'http://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json'. 此请求已被阻止;内容必须通过HTTPS提供。

将您的url更改为协议,从
http
更改为
https

https://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json

这应该行得通


如果检查浏览器控制台,您应该会看到以下错误

jquery git.js:9648混合内容:页面位于'https://jsfiddle.net/'已通过HTTPS加载,但请求了不安全的XMLHttpRequest终结点'http://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json'. 此请求已被阻止;内容必须通过HTTPS提供。

将您的url更改为协议,从
http
更改为
https

https://api.wunderground.com/api/24b969202160514e/geolookup/conditions/q/Turkey/zmw:00000.58.17352.json

这应该行得通


为什么不使用jQuery


为什么不使用jQuery


我在控制台中找不到任何错误。我将http更改为https但不起作用。@bukalemun,检查链接我在控制台中找不到任何错误。我将http更改为https但不起作用。@bukalemun,请检查链接试用
成功
,而不是
完成
,我想您可能无法使用文档。请在文档准备就绪后编写。您可以使用jquery修改内容或将内容附加到页面中的某些元素。@prasanth我尝试了,但没有成功。实际上代码是可以工作的,但我想在页面上编写原始json。它是用html>body编写的。但它在success或done函数之外编写原始json。如何在页面上编写原始json。没有html>body。请使用打印为文本的某些元素
$('some element')。text(yourjsonstring)
尝试
成功
而不是
完成
我认为您可能无法使用文档。请在文档准备就绪后编写。您可以使用jquery修改内容或将内容附加到页面中的某些元素。@prasanth我尝试了,但没有成功。实际上代码是可以工作的,但我想在页面上编写原始json。它是用html>body编写的。但它在success或done函数之外编写原始json。如何在页面上编写原始json。没有html>body。请使用打印为文本的某些元素<代码>$('some element')。文本(yourjsonstring)
实际上代码是有效的,但我想在页面上编写原始json。它是用html>body编写的。但它在success或done函数之外编写原始json。实际上代码是工作,但我想在页面上编写原始json。它是用html>body编写的。但它在success或done函数之外编写原始json。
$.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);
})