Ajax请求后台发送String类型总是进入Error function解决办法总结 最近写一个新的项目,测试环境搭建下服务端向客户端发送数据,并在页面请求下相应这些数据,遇到请求发起后总是进入error函数,但数据在console.log后依然携带到客户端了 ,查了很多资料,也咨询了前端开发的好友,先总结一下解决办法。因为我发送的是String类型
which in Fiddler comes back as {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}. I have several other web services similar to the one giving an error that work fine, the only difference between them is the one in question returns a string...
向ajax的错误函数发送参数可以通过在ajax请求中使用error回调函数的方式实现。在error回调函数中,可以通过传递参数的方式将错误信息发送给该函数。 具体实现步骤如下: 在ajax请求中,设置error回调函数,例如: 代码语言:txt 复制 $.ajax({ url: 'your_url', type: 'GET', success: function(response) { // 请求...
this.errorToXML = errorToXML; this.log = log; } 接下来,我们定义了一个方法,它会把Error对象序列化为XML。在默认情况下,Error对象只有两种属性,分别是name和message,但是我们还是使用了第三个属性(location),它有时候是有用的。 // 把错误映射到XML文档中 function errorToXML(err) { var xml = ’<?
},error:function(message) {console.log("error")console.log(message.responseText) } }); XMLHttpRequest 是 AJAX 的基础。我们直接利用XMLHttpRequest构建请求。 functionajax(req){varxhr=newXMLHttpRequest(); xhr.onreadystatechange=function(){if(xhr.readyState===4){ ...
};functionAjaxError(msg){this.name="Ajax错误";this.message=msg||"未知错误"; } ajax.prototype={init:function(option){this[0]=this.create();//创建Ajax对象this[1]={url:option.url||"",//数据源地址method:option.method||"GET",//请求方法[POST、HEAD...]data:option.data||null,//要发送...
default:httpRequest.open("GET",e.target.innerHTML+".html");break;}httpRequest.send();}catch(error){displayErrorMsg("try/catch",error.message);}}functionhandleError(e){displayErrorMsg("Error event",httpRequest.status+httpRequest.statusText);}functionhandleResponse(){if(httpRequest.readyState==...
function onInvoke(sender, args) { //ShowProgress('Processing ...'); } function onComplete(sender, args) { $find('<%= mpeProgress.ClientID %>').hide(); } function ShowProgress(msg) { $('#divProgressMessage').html(msg); $find('<%= mpeProgress.ClientID %>').show(); ...
jqueryajax中error返回错误解决办法 进入百度搜索此问题,发现有人这么说了一句Jquery中的Ajax的async默认是true(异步请求),如果想一个Ajax执行完后再执行另一个Ajax, 需要把async=false就可以了于时我在ajax中进行了处理async: false,结果发现提交正常的数据返回是正常的没有错误。 代码如下复制代码$.ajax({type: "...
log('Contents: ' + json); }, function(error) { console.error('出错了', error); }); 3. 服务器响应处理(区分同步跟异步两种情况) responseText 获得字符串形式的响应数据。responseXML 获得XML 形式的响应数据。 同步处理 xhr.open("`GET`","info.txt",false); xhr.send(); document.`GET`...