Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Call WebPage Method doesn't work
    text
    copied!<p>I do </p> <pre><code>&lt;script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function CallPageMethod(methodName, onSuccess, onFail) { var args = ''; var l = arguments.length; if (l &gt; 3) { for (var i = 3; i &lt; l - 1; i += 2) { if (args.length != 0) args += ','; args += '"' + arguments[i] + '":"' + arguments[i + 1] + '"'; } } var loc = window.location.href; loc = (loc.substr(loc.length - 1, 1) == "/") ? loc + "Report.aspx" : loc; $.ajax({ type: "POST", url: loc + "/" + methodName, data: "{" + args + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: onSuccess, fail: onFail }); } function success(response) { alert(response.d); } function fail(response) { alert("&amp;#1054;&amp;#1096;&amp;#1080;&amp;#1073;&amp;#1082;&amp;#1072;."); } function select() { ........... CallPageMethod("SelectBook", success, fail, ...........); } &lt;/script&gt; </code></pre> <p>And my Script Manager is </p> <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePageMethods="true" EnablePartialRendering="true" runat="server" /&gt; </code></pre> <p>But when I execute select function I got nothing ... no messages at all.</p> <p>Error log :</p> <pre><code> [ArgumentException]: Unknown web method SelectBook. Parameter name: methodName at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) at System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) </code></pre> <p>And my web method :</p> <pre><code>&lt;WebMethod()&gt; Public Function SelectBook(ByVal values As String, ByVal valuesG As String, ByVal valuesX As String, ByVal valuesXG As String) As String '.... Return If(((vals.Length = valsG.Length) And (valsX.Length = valsXG.Length)), SQLModule.UpdateAdvCode(vals, valsG, valsX, valsXG), "Ошибка чтения диспетчерских кодов") End Function </code></pre> <p>If I only do alert( CallPageMethod("SelectBook", success, fail, ...........) ) I can see "undefined" , but what undefined ??? I was tried to debug this javascript but can't fix it. It was worked and I understand how it must works, but I just have no idea why it is broken for now and how to fix it. Help me with it please.</p> <p>Some more information</p> <pre><code> Server ASP.NET Development Server/10.0.0.0 Date Thu, 03 Feb 2011 11:30:51 GMT X-AspNet-Version 4.0.30319 Cache-Control private Content-Type text/html; charset=utf-8 Content-Length 3517 Connection Close </code></pre> <p>why close ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload