ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Execute multiple jQuery AJAX call one after the end of other in ASP.Net using C# and VB.Net<p>Hi&nbsp;jovceka,</p> <p>All you need to do is to call the 2nd function on the success of first ajax request.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;div&gt; Name&amp;nbsp;:&amp;nbsp;&lt;b&gt;&lt;asp:Label ID=&#34;lblName&#34; runat=&#34;server&#34; /&gt;&lt;/b&gt; &lt;br /&gt; Country&amp;nbsp;:&amp;nbsp;&lt;b&gt;&lt;asp:Label ID=&#34;lblCountry&#34; runat=&#34;server&#34; /&gt;&lt;/b&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { function1(); }); function function1() { $.ajax({ type: &#34;POST&#34;, contentType: &#34;application/json; charset=utf-8&#34;, url: &#34;WebService.asmx/f1&#34;, data: {}, dataType: &#34;json&#34;, success: function (data) { $(&#39;#lblName&#39;).html(data.d); function2(); }, error: function () { alert(&#34;Error while Showing update data&#34;); } }); } function function2() { $.ajax({ type: &#34;POST&#34;, url: &#34;WebService.asmx/f2&#34;, data: &#39;{}&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function (data) { $(&#39;#lblCountry&#39;).html(data.d); }, error: function (response) { alert(&#34;Error&#34;); } }); } &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">Web Service</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Web.Services; /// &lt;summary&gt; /// Summary description for WebService /// &lt;/summary&gt; [WebService(Namespace = &#34;http://tempuri.org/&#34;)] [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] public class WebService : System.Web.Services.WebService { [WebMethod] public string f1() { return &#34;Mudassar Khan&#34;; } [WebMethod] public string f2() { return &#34;India&#34;; } } </pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols &#39; To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. &lt;System.Web.Script.Services.ScriptService()&gt; _ &lt;WebService(Namespace:=&#34;http://tempuri.org/&#34;)&gt; _ &lt;WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _ &lt;Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()&gt; _ Public Class WebService Inherits System.Web.Services.WebService &lt;WebMethod()&gt; _ Public Function f1() As String Return &#34;Mudassar Khan&#34; End Function &lt;WebMethod()&gt; _ Public Function f2() As String Return &#34;India&#34; End Function End Class</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <p>Name&nbsp;:&nbsp;<strong>Mudassar Khan</strong> </p> <p>Country&nbsp;:&nbsp;<strong>India</strong></p>https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/Thu, 06 Dec 2018 23:25:58 GMTExecute multiple jQuery AJAX call one after the end of other in ASP.Net using C# and VB.Net<p>thank you sir for your valuable reply..is there any other method other than this..</p>https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/Fri, 07 Dec 2018 03:42:22 GMTExecute multiple jQuery AJAX call one after the end of other in ASP.Net using C# and VB.Net<p>Hi jovceka,</p> <p>Yes. You can set&nbsp;<span style="text-decoration: underline;">async:false</span> in the ajax call.</p> <p>So that other code will wait for the statement you are calling to finish.</p> <p>Then you can call the function on after another&nbsp;instead of calling the 2nd function inside success function of&nbsp;1st.</p> <p>But one issue is if you got error on 1st function your 2nd function still executed.</p> <p>Example:</p> <pre class="brush: js">&lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { function1(); function2(); }); function function1() { $.ajax({ type: &#34;POST&#34;, contentType: &#34;application/json; charset=utf-8&#34;, url: &#34;WebService.asmx/f1&#34;, data: {}, dataType: &#34;json&#34;, async: false, success: function (data) { $(&#39;#lblName&#39;).html(data.d); //function2(); }, error: function () { alert(&#34;Error while Showing update data&#34;); } }); } function function2() { $.ajax({ type: &#34;POST&#34;, url: &#34;WebService.asmx/f2&#34;, data: &#39;{}&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, async: false, success: function (data) { $(&#39;#lblCountry&#39;).html(data.d); }, error: function (response) { alert(&#34;Error&#34;); } }); } &lt;/script&gt;</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/104273/Execute-multiple-jQuery-AJAX-call-one-after-the-end-of-other-in-ASPNet-using-C-and-VBNet/Fri, 07 Dec 2018 04:07:18 GMT