【发布时间】:2011-03-18 12:01:17
【问题描述】:
我在处理 json 时遇到了一些问题,请帮助我 T.T 我的 ajax
//submit the form
$.ajax({
type: "POST",
url: url,
data: $('#form').serialize(),
dataType: "json",
success: function(resp){
alert(resp);
$('#' + thediv).html(resp);
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
它只是警报(200)然后警报(取消定义)
当我将数据类型更改为 html 时,所有数据都可以检索 但是 json 文件是分页打印的, 这是扩展问题吗?
我的 Json 文本
{
"menu": "File",
"commands": [
{
"title": "New",
"action":"CreateDoc"
},
{
"title": "Open",
"action": "OpenDoc"
},
{
"title": "Close",
"action": "CloseDoc"
}
]
}
【问题讨论】:
-
服务器发送的 Content-Type 是什么?它应该是应用程序/json。您可以通过 Firebug 或 curl 等方式确定当前值。