ASP.net PageMethods return undefined

前端 未结 2 835
花落未央
花落未央 2021-01-24 00:44

Hi everyone i trying to get data from cs to js using ToolkitScriptManager. this is my aspx :

    


        
2条回答
  •  后悔当初
    2021-01-24 00:51

    You need to supply a success and a failure callback to the webmethod call as below.

      $(window).load(function () {
                                        PageMethods.isConnected(fnsuccesscallback,fnerrorcallback);
    
            });
            function fnsuccesscallback(data) {
                alert(data);
    
            }
            function fnerrorcallback(result) {
                alert(result.statusText);
            }
    

    Also, there is another way of accessing the page methods using $.ajax.

    
        
        
        
        
    
    
        

提交回复
热议问题