title: Modal Button not registering on click
body: <p>I'm pretty new to MVC development and am working on an application to submit raffle tickets. I believe my issue is with my script, once I start adding variables and ajex to post the data, the button doesn't respond.</p>
  <p>Any help or recommendations is greatly appreciated.</p>
  <p>Below is my my script and Modal, the piece that is commented out in the script is where the button fails</p>
  <p>//Controller</p>
  <pre><code>using HR.HolidayFamiliesApplication.Web.Models;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Logging;
  using System;
  using System.Collections.Generic;
  using System.Diagnostics;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace HR.HolidayFamiliesApplication.Web.Controllers
  {
      public class HomeController : Controller
      {
          private readonly ILogger&lt;HomeController&gt; _logger;
  
          public IActionResult Index()
          {
              return View();
          }
  
          public IActionResult Privacy()
          {
              return View();
          }
  
          [ResponseCache(Duration = 0, Location = 
          ResponseCacheLocation.None, NoStore = true)]
          public IActionResult Error()
          {
              return View(new ErrorViewModel { RequestId = 
          Activity.Current?.Id ?? HttpContext.TraceIdentifier });
          }
  
          private readonly ConnectionDB _db;
  
          public HomeController(ConnectionDB db)
          {
              _db = db;
          }
  
          public JsonResult InsertRecords(RaffleSubmissions submissions)
          {
              RaffleSubmissions rs = new RaffleSubmissions();
              submissions.Raffle_ID = rs.Raffle_ID;
              submissions.Raffle_Item_Name = rs.Raffle_Item_Name;
              submissions.Number_of_Tickets = rs.Number_of_Tickets;
              submissions.User_Name = rs.User_Name;
              submissions.Insert_Date = rs.Insert_Date;
  
              _db.HolidayFamilies_Raffle_Submissions.Add(submissions);
              _db.SaveChangesAsync();
              return Json(submissions);
          }
  
          public IActionResult RaffleList()
          {
              var results = _db.HolidayFamilies_Raffles.ToList();
              return View(results);
          }
  
          public ActionResult Details(int Id)
          {
              RaffleList frnds = new RaffleList();
              frnds = _db.HolidayFamilies_Raffles.Find(Id);
              return PartialView(&quot;_Details&quot;, frnds);
          }
  
      }
  }
  </code></pre>
  <p>//View</p>
  <pre><code>    @model IEnumerable&lt;HR.HolidayFamiliesApplication.Web.Models.RaffleList&gt;
  
  @{
      ViewData[&quot;Title&quot;] = &quot;RaffleList&quot;;
  }
  
  &lt;h2&gt;Holiday Family Raffles&lt;/h2&gt;
  
  &lt;table class=&quot;table&quot;&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Raffle_ID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Raffle_Item_Name)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Raffle_Item_Description)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Raffle_ID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Raffle_Item_Name)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Raffle_Item_Description)
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;button type=&quot;button&quot; class=&quot;anchorDetail&quot; data-toggle=&quot;modal&quot; data-target=&quot;#exampleModal&quot; data-id=&quot;@item.Raffle_ID&quot;&gt;
                      Submit Tickets
                  &lt;/button&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  
  
  &lt;!-- Modal --&gt;
  &lt;div class=&quot;modal fade&quot; id=&quot;exampleModal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;exampleModalLabel&quot; aria-hidden=&quot;true&quot;&gt;
      &lt;div class=&quot;modal-dialog&quot; role=&quot;document&quot;&gt;
          &lt;div class=&quot;modal-content&quot;&gt;
              &lt;div class=&quot;modal-header&quot;&gt;
                  &lt;h5 class=&quot;modal-title&quot; id=&quot;exampleModalLabel&quot;&gt;Modal title&lt;/h5&gt;
                  &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;
                      &lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;
                  &lt;/button&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-body&quot;&gt;
                  &lt;p&gt;
                      Raffle Tickets: &lt;input type=&quot;number&quot; id=&quot;txtnumber&quot; /&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-footer&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot; id=&quot;btinsert&quot;&gt;Save changes&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;bootstrap/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
  
  
  &lt;script&gt;
      $(&quot;#btinsert&quot;).click(function () {
          $.ajax({
              type: 'POST',
              url: '../Home/InsertRecords',
              data: {
                  &quot;Raffle_ID&quot;: id, &quot;Raffle_Item_Name&quot;: &quot;&quot;, &quot;Number_of_Tickets&quot;: txtnumber.val(), &quot;User_Name&quot;: &quot;&quot;, &quot;Insert_Date&quot;: Date.now()
              },
              dataType: &quot;json&quot;,
              contentType: &quot;application/json; charset=utf-8&quot;,
              success: function (data) {
  
              }
              ,
              error: function (ex) {
                  alert('Failed to retrieve data : ' + ex);
              }
          });
  
          alert(&quot;Tickets have been submitted&quot;);
      });
  &lt;/script&gt;
  
   $.ajax({
              type: 'POST',
              url: '../Home/InsertRecords',
              data: {
                      &quot;Raffle_ID&quot;: id, &quot;Raffle_Item_Name&quot;: &quot;&quot;, &quot;Number_of_Tickets&quot;: txtnumber.val(), &quot;User_Name&quot;: &quot;&quot;, &quot;Insert_Date&quot;: Date.now()
                    },
              dataType: &quot;json&quot;,
              contentType: &quot;application/json; charset=utf-8&quot;,
              success: function (data) {
  
              }
               ,
              error: function (ex) {
                  alert('Failed to retrieve data : ' + ex);
              }
          });
  </code></pre>