开发者

Is it true that jQuery 1.6.2 automatically evals on the json response?

开发者 https://www.devze.com 2023-04-01 20:57 出处:网络
I thought result will be a json object if the response header includes application/json, $.get(...,function(result){

I thought result will be a json object if the response header includes application/json,

$.get(...,function(result){
    //here result is a json object
});

But today I tried a earlier version of jQuery,found result is a string.

So is it true that jQuery 1.6 automatically converts the result to object(eval("("+result+")")) for me开发者_运维知识库?

UPDATE

Here's the related header,but it turns out I have to eval it manually:

X-Content-Type-Options  nosniff
Content-Type    application/json; charset=EUC-JP

UPDATE

No doubt now,it's confirmed.


If the server sets the Content-Type: application/json response header, jQuery automatically evals the result, and this is true even for older versions.


Yes, this feature doesn't exist in jquery 1.3.2

0

精彩评论

暂无评论...
验证码 换一张
取 消