三生石@ 2016-02-17 15:01 采纳率: 100%
浏览 27

Ajax调用未返回错误

I have some ajax code on the client side like this:

$.ajax({
                type: "POST",
                url: "frmPNList.aspx/ChangeGroupOfUSNs",
                async: false,
                contentType: "application/json; charset=utf-8",
                //data: '{strNewUSN: "' + usn.value + '", strURNs: "' + id[1] + '", strDatasetName: "' + id[2] + '", strCon: "' + $("#<%=fieldGenieConnectionString.ClientID%>")[0].value + '"}',
                data: '{strNewUSN: "' + usn.value + '", arrayURNDataset: ' + JSON.stringify(strURNDataset) + ', strCon: "' + connectionstring.value + '", strUserNameLocal: "' + username.value + '"}',
                //data: '{strNewUSN: 9, strURNs: 1, strDatasetName: 2}',
                dataType: "json",
                success: OnSuccess(),
                error: function (xhr, errorType, exception) {
                    var errorMessage = exception || xhr.statusText; //If exception null, then default to xhr.statusText
                    alert("there was an error changing the USN of the group: " + errorMessage);
                },
                failure: function () {
                    alert('there was an error changing the USN of the group.')

                }
            });

            function OnSuccess() {
                return function () {

                }
            }
            //end of AJAX call

and on the server side:

    <System.Web.Services.WebMethod()> _
        Public Shared Sub ChangeGroupOfUSNs(ByVal strNewUSN As String, ByVal arrayURNDataset As String, ByVal strCon As String, ByVal strUserNameLocal As String)
Try
            Throw New Exception
        Catch ex As Exception

        End Try
    End Sub

The failure message is not called. Why is this?

  • 写回答

1条回答 默认 最新

  • python小菜 2016-02-17 15:04
    关注

    Failure only gets triggered when something goes wrong with the request itself (error 404, error 500, etc). It does not return PHP/ASP errors.

    If you want to check PHP/ASP errors you'll have to make that yourself (in the done function you can create some if statements).

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题