我的代码是这样的:
function EditData(){
//$.messager.progress(); // display the progress bar
$('#ff2').form('submit', {
type: "Put",
contentType: "text/html",
dataType: "text/html",
accept: "text/plain; charset=utf-8",
onSubmit: function () {
var isValid = $(this).form('validate');
if (!isValid) {
$.messager.progress('close'); // hide progress bar while the form is invalid
}
return isValid; // return false will stop the form submission
},
success: function (data) {
alert(data);
//data = $.parseJSON(data);
if (data.state == "success") {
$.messager.alert('Success', 'Success');
CloseWindow('w2');
} else {
$.messager.alert('Failed', 'Failed');
}
$.messager.progress('close'); // hide progress bar while submit successfully
}
});
//$('#ff2').submit();
}
通过Firefox,返回的数据为:
{"state":"success","message":"1","sql":"**"}
然而,当我像这样使用时:
alert(data.state);
Firefox像这样流行:
<div id="json">{<ul class="obj collapsible"><li><span class="prop"><span class="q">"</span>state<span class="q">"</span></span>: <span class="string">"success"</span>,</li><li><span class="prop"><span class="q">"</span>message<span class="q">"</span></span>: <span class="string">"1"</span>,</li><li><span class="prop"><span class="q">"</span>sql<span class="q">"</span></span>: <span class="string">"**"</span></li></ul>}</div>
任何人都可以帮助我吗?
答案 0 :(得分:0)
你可以禁止使用firefox的jsonview。
返回的数据如下:
data=eval("("+data+")");