0x800a138a-JavaScript运行时错误:AJAX调用中需要函数

0x800a138a-JavaScript运行时错误:AJAX调用中需要函数,javascript,jquery,asp.net,ajax,vb.net,Javascript,Jquery,Asp.net,Ajax,Vb.net,请参阅下面的代码: <script type="text/javascript" src="Javascript/json2.js"></script> <script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script> <script type = "text/javascript"> function GroupUSNChange(

请参阅下面的代码:

<script type="text/javascript"  src="Javascript/json2.js"></script>
     <script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>
<script type = "text/javascript">
function GroupUSNChange() {
        alert("got here");
        var frm = document.forms[0];
        var usn = document.getElementById("ctl00_ContentPlaceHolder1_hfUSN");
        for (i = 0; i < frm.elements.length; i++) {
            if (frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(0, 38) == "ctl00$ContentPlaceHolder1$RematchGroup") {
                if (frm.elements[i].checked == true) {

                    var id = frm.elements[i].name.split("|");
                    alert(id[1]);
                    alert(id[2]);
                    alert(usn.value);

                    $.ajax({
                        type: "POST",
                        url: "frmPNList.aspx/ChangeGroupOfUSNs",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({ strNewUSN: usn, strURNs: id(1), strDatasetName: id(2) }),
                        dataType: "json",
                        success: OnSuccess(response),
                        error: function (xhr, errorType, exception) {
                            var errorMessage = exception || xhr.statusText; //If exception null, then default to xhr.statusText  
                            alert("there was an error changing USNs: " + errorMessage);
                        },
                        failure: function (response) {
                            alert('there was a problem changing USNs.')

                        }
                     });
                    function OnSuccess() {
                        return function (response) {
                            //alert('got here 2')
                            alert('Successfully changed USNs')
                        }
                    }



                }
            }
        }
    }
</script>

函数GroupUSNChange(){
警惕(“到达这里”);
var frm=document.forms[0];
var usn=document.getElementById(“ctl00\u ContentPlaceHolder1\u hfUSN”);
对于(i=0;i
以及背后的代码:

<System.Web.Services.WebMethod()> _
    Public Shared Function ChangeGroupOfUSNs(ByVal strNewUSN As String, ByVal strURNs As String, ByVal strDatasetName As String) As String

        Dim intUSN As Integer = CInt(strNewUSN)

        Return "done"
    End Function
_
公共共享函数ChangeGroupOfUSNs(ByVal strNewUSN作为字符串,ByVal strURNs作为字符串,ByVal strDatasetName作为字符串)作为字符串
作为整数的Dim intUSN=CInt(strNewUSN)
返回“完成”
端函数
错误出现在起始行:
$.ajax({


id和USN包含正确的值。为什么会出现此错误?

您正在调用成功处理程序:

success: OnSuccess(response),
                  ^^^^^^^^^^
当它应该更像:

success: function(data) { OnSuccess(data); }

您正在呼叫您的成功处理程序:

success: OnSuccess(response),
                  ^^^^^^^^^^
当它应该更像:

success: function(data) { OnSuccess(data); }