jQuery如何找出ajax错误是什么? [英] JQuery How to find out what the ajax error is?

查看:97
本文介绍了jQuery如何找出ajax错误是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我只是通过在萤火虫中运行来尝试

I have the following bit of code which I'm just trying out by running in firebug

$.ajax({
  type:"POST",
  url:"http://mpdomain/WebService.asmx/Operation",
  data: "{'parameter1': '44906'}", 
  contentType: "application/json;charset=utf-8",
  dataType: "json",
  success: function(data) { alert("succsess") },
  error: function(e, ts, et) { alert(ts) }
})

理论上它应该起作用.但是,将触发错误处理程序,并且ts只是设置为"error".如何获得更多有关发生问题的详细信息?

In theory it should work. However the error handler is triggered, and ts is simply set to "error". How do I get more detail about what's gone wrong?

推荐答案

$.ajax({
  type:"POST",
  url:"http://mpdomain/WebService.asmx/Operation",
  data: "{'parameter1': '44906'}", 
  contentType: "application/json;charset=utf-8",
  dataType: "json",
  success: function(data) { alert("succsess") },
  error: function(ts) { alert(ts.responseText) }
})

这篇关于jQuery如何找出ajax错误是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆