首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

jquery ajax 返回方法有关问题

2012-09-05 
jquery ajax 返回方法问题JScript code function EvidenceBind(){var investigationId1 $.ajax({type:

jquery ajax 返回方法问题

JScript code
 function EvidenceBind()   {        var investigationId=1; $.ajax({                type: "post",                url: " ashx/FrmSelectEvidence.ashx",                data:{investigationId:investigationId},                datatype: "json",                success: function (json) {                alert("chen");                    var arrE=new Array();                    $.each(json, function (index,item) {                          arrE.push("<tr class='deleteEvidence'>");                         arrE.push("<td>"+item.evidenceTypeName+"</td>");                         arrE.push("<td>"+item.speciesName+"</td>");                         arrE.push("<td>"+item.count+"</td>");                         arrE.push("<td>"+item.remark+"</td>");                         arrE.push("<td></td>");                         arrE.push("<td><input type='button' value='删除' id='btnDeleteEvidence' /></td>");                         arrE.push("</tr>");                         var str=arrE.join(" ");                         $("#tEvidenceType").append(str);                                             });                },                error: function (textStatus, XMLHttpRequest, errorThrown) {                                       alert(textStatus.d);                                    alert(XMLHttpRequest.status);                                      alert(XMLHttpRequest.readyState);                    alert(errorThrown);                }            });

json:[{"count":"1","remark":"ceshi","evidenceTypeName":"测试证据类型","speciesName":"测试种类1","id":"10"},{"count":"1","remark":"ceshi","evidenceTypeName":"测试证据类型","speciesName":"测试种类1","id":"11"},{"count":"3","remark":"测试","evidenceTypeName":"测试证据类型2","speciesName":"测试种类2","id":"13"},{"count":"5","remark":"fangshi","evidenceTypeName":"测试证据类型2","speciesName":"测试种类2","id":"14"}]

为什么谷歌执行的是success,ie执行的事error方法,求解

[解决办法]
可能出乱码了,你error配置参数顺序搞错了,而且XMLHttpRequest为系统对象,最好不要随便命名参数为系统的对象,要不可能发生乱七八糟的错误

输出responseText看看是什么东东

error: function (xhr,textStatus, errorThrown) {
alert(xhr.responseText)
}


[解决办法]
先改ashx为get提交,然后用浏览器访问ashx/FrmSelectEvidence.ashx?investigationId=参数看看有数据输出没有。

热点排行