[英]Object attributes change when it return from Jquery function
Given the follow - 鉴于以下情况-
index.html 的index.html
var jsonOut = $.getJSON("graph.json", function (jsonIn) {
console.log(jsonIn);
return jsonIn;
});
console.log(jsonOut);
graph.json - contain a long JSON
format . graph.json-包含长JSON
格式。
The - console.log(jsonIn)
output is - console.log(jsonIn)
输出为-
Object {aaaa: Array[7], bbbb: Array[7], cccc: Array[7]}
But the - console.log(jsoOut)
output is - 但是console.log(jsoOut)
输出是-
Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
Why does jsonIn
and jsonOut
seems different ? 为什么jsonIn
和jsonOut
看起来不同? and how could I make jsonOut exactly same as jsonOut
? 我怎么能让jsonOut完全相同的jsonOut
?
jsonOut
is the actual ajax object. jsonOut
是实际的ajax对象。
You dont need it (Usually ) inside the method. 你不需要它(通常)的方法内 。
Usually it is used by others who want to do something with this promise object. 通常,其他想要对该承诺对象执行某些操作的人都使用它。 ( done
, fail
, always
) ( done
, fail
, always
)
In short - you want jsonIn
简而言之-您想要jsonIn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.