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.Pass (Send) List from Controller to View using jQuery AJAX in ASP.Net MVC<p>Hi <a class="username" rel="Ah1970"> Ah1970</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { $(&#39;#btnPrintToken&#39;).click(function () { $.ajax({ url: &#39;Home/btnPrintToken&#39;, type: &#39;POST&#39;, dataType: &#39;json&#39;, success: function (N) { $(&#39;#listTokens&#39;).empty(); var listTokens = $(&#39;#listTokens&#39;); $(N).each(function (index, x) { var option = $(&#34;&lt;option /&gt;&#34;); option.html(x); option.val(x); listTokens.append(option); }); } }); }); }); &lt;/script&gt; &lt;select id=&#34;listTokens&#34; style=&#34;width: 100px&#34;&gt; &lt;/select&gt; &lt;input type=&#34;button&#34; id=&#34;btnPrintToken&#34; value=&#34;Print Token&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } public JsonResult btnPrintToken() { if (Session[&#34;Tokenqueu&#34;] == null) { Queue&lt;int&gt; queueToken = new Queue&lt;int&gt;(); Session[&#34;Tokenqueu&#34;] = queueToken; } List&lt;int&gt; listnumbertoken = new List&lt;int&gt;(); Queue&lt;int&gt; tokenQueue = (Queue&lt;int&gt;)Session[&#34;Tokenqueu&#34;]; //string mesg = &#34;There are&#34; + tokenQueue.Count.ToString() + &#34;Customer in the queue before you&#34;; if (Session[&#34;Lastnumbertoken&#34;] == null) { Session[&#34;Lastnumbertoken&#34;] = 0; } int nextnumbertoken = (int)Session[&#34;Lastnumbertoken&#34;] + 1; Session[&#34;Lastnumbertoken&#34;] = nextnumbertoken; tokenQueue.Enqueue(nextnumbertoken); foreach (int token in tokenQueue) { listnumbertoken.Add(token); } return Json(listnumbertoken, JsonRequestBehavior.AllowGet); } }</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/vJxoK9S.gif" alt="" width="241" height="184" /></span></strong></p>https://www.aspforums.net:443/Threads/207247/Pass-Send-List-from-Controller-to-View-using-jQuery-AJAX-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/207247/Pass-Send-List-from-Controller-to-View-using-jQuery-AJAX-in-ASPNet-MVC/Fri, 30 Aug 2019 02:13:50 GMT