ajax call HELPPPhttp://forums.asp.net/t/1787781.aspx/1?ajax+call+HELPPPWed, 04 Apr 2012 05:25:05 -040017877814910169http://forums.asp.net/p/1787781/4910169.aspx/1?ajax+call+HELPPPajax call HELPPP <p>Hi there,</p> <p>The following code is a very simple ajax call to server that alerts back on success and complete events.</p> <p>From a reason I cannot understand on my development machine it works fins and alerts on success and complete but on server it never alerts on success. WHY ???</p> <pre class="prettyprint">&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head runat=&quot;server&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;script src=&quot;Scripts/jquery-1.7.1.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; function dummy() { $.ajax({ url: 'services/chatEngine.asmx/dummy', async: true, type: &quot;POST&quot;, complete: function () { alert('Done'); }, success: function (a, b, c) { alert('Success'); } }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;ajaxToolkit:ToolkitScriptManager ID=&quot;ToolkitScriptManager1&quot; runat=&quot;server&quot;&gt; &lt;/ajaxToolkit:ToolkitScriptManager&gt; &lt;div id=&quot;userList&quot;&gt;Users:&lt;br /&gt;&lt;/div&gt; &lt;input id=&quot;Button3&quot; type=&quot;button&quot; value=&quot;dummy&quot; onclick=&quot;dummy()&quot; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p>The server side dummy function returns nothing, code follows -</p> <pre class="prettyprint">&lt;WebMethod(True)&gt; Public Function dummy() As String Return "" End Function</pre> 2012-04-01T07:40:04-04:004910312http://forums.asp.net/p/1787781/4910312.aspx/1?Re+ajax+call+HELPPPRe: ajax call HELPPP <p>I suspect that when the deployed the url is wrong.&nbsp; You can use a tool like fiddler to monitor where the ajax call is going.</p> 2012-04-01T10:40:46-04:004910823http://forums.asp.net/p/1787781/4910823.aspx/1?Re+ajax+call+HELPPPRe: ajax call HELPPP <p>function CallService()&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var name = &#36;(&quot;#taYourName&quot;).text();&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; //Also check whether you're getting the name before you call the webservice</p> <p>&nbsp;&nbsp;&nbsp; // alert(name) &nbsp;&nbsp;&nbsp;&nbsp; &#36;.ajax(&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type: &quot;POST&quot;,&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>contentType: &quot;application/json; charset=utf-8&quot;,</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url: &quot;YourNameIs.asmx/YourName&quot;,&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>&nbsp; data: &quot;{ 'yourName': '&quot;&#43;name&#43;&quot;' }&quot;,</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; success: function (msg) {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>&#36;(&quot;#lblForAjax&quot;).text(msg.d);&nbsp; </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; });</p> <p>Check below url's you'll have idea..</p> <p><a href="http://dotnetslackers.com/articles/ajax/using-jquery-with-asp-net.aspx#consuming-a-web-service-using-asp-net-ajax">http://dotnetslackers.com/articles/ajax/using-jquery-with-asp-net.aspx#consuming-a-web-service-using-asp-net-ajax</a></p> <p><a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/</a></p> 2012-04-02T03:32:59-04:004915078http://forums.asp.net/p/1787781/4915078.aspx/1?Re+ajax+call+HELPPPRe: ajax call HELPPP <p>The solution for this headache follows -</p> <p>Instead of: <strong><span class="pln">url</span><span class="pun">:</span><span class="pln"> </span><span class="str">'services/chatEngine.asmx/dummy'</span><span class="pun">,</span></strong></p> <p>I used: <strong>url:&nbsp;<span style="color:maroon">'services/chatEngine.asmx?op=dummy'</span>,</strong></p> <p></p> <p>Thanks for everyone</p> 2012-04-04T05:25:05-04:00