首页 > $.post请求返回数据问题

$.post请求返回数据问题

服务端返回的确实是json格式,但是我直接msg.title是空的,为什么?取json不就是这么取的吗?

$.post("/action/save",{category:'sort', tid:914},function(msg){
    console.log(msg.title);
});

你漏了$.post()最后一个参数了,要加上json的。

$.post("/action/save",{category:'sort', tid:914},function(msg){
    console.log(msg.title);
}, json); //这里还有个参数,你去看看手册就知道了

嗯,一楼兄弟回答的很好,题主确实漏了最后面的参数了。$.post

【热门文章】
【热门文章】