Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy my CallBack function doesnt works?
    primarykey
    data
    text
    <p>I'm trying to make some calls to a WebService</p> <p>I did exactly what is described in this article</p> <p><a href="http://viralsarvaiya.wordpress.com/2010/03/23/calling-web-service-from-java-script-in-asp-net-c/" rel="nofollow">http://viralsarvaiya.wordpress.com/2010/03/23/calling-web-service-from-java-script-in-asp-net-c/</a></p> <p>Looking at the console of firebug I could see that my function was executed and returned the expected data, but my callback functions (OnComplete, OnError, OnTimeOut) are never executed.</p> <p>Whats wrong?</p> <p>Here is the code (same code of the article) Service.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; [WebService(Namespace = "http://Localhost...xys/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] [System.Web.Script.Services.ScriptService()] public class Service : System.Web.Services.WebService { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld(string strNoOfData) { return strNoOfData; } } </code></pre> <p>Default.aspx</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript" language="javascript"&gt; function CallService() { Service.HelloWorld(document.getElementById('Textbox1').value, OnComplete, OnError, OnTimeOut); } function OnComplete(Text) { alert(Text); } function OnTimeOut(arg) { alert("timeOut has occured"); } function OnError(arg) { alert("error has occured: " + arg._message); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;Services&gt; &lt;asp:ServiceReference Path="~/Service.asmx" /&gt; &lt;/Services&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"&gt; &lt;ContentTemplate&gt; &lt;fieldset&gt; &lt;asp:TextBox ID="Textbox1" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; &lt;asp:Button ID="Button1" runat="server" Text="Call Service" OnClientClick="CallService()" /&gt; &lt;/fieldset&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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