title: error:Failed to load resource: the server responded with a status of 500 (Internal Server Error in asp.net
body: <p>what am getting wrong: ajax code.Getting error </p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 500 (Internal Server Error)</p>
  </blockquote>
  
  <p>i have really searched can figure out what is wrong. on second try without changing anything i get this error</p>
  
  <blockquote>
    <p>POST 
        <a href="http://localhost:51477/Customers/SaveCustomer" rel="nofollow noreferrer">http://localhost:51477/Customers/SaveCustomer</a> 500 (Internal Server Error)</p>
  </blockquote>
  
  <pre><code>   $(document).ready(function () {
        $("#btnSave").click(function () {
  
          var data = JSON.stringify({
              _id: $("#Customerid").val(),
              customertype: $("#CustomerType option:selected").val(),
              pricetype: $("#Pricetype option:selected").val(),
              customername: $("#Customername").val(),
              idnumber: $("#Idnumber").val(),
              contact: $("#Contact").val(),
              location: $("#Location").val(),
              loyaltycard: $("#loyalty").val(),
              creditlimit: $("#credit").val(),
              remainingcredit: $("#credit").val()
          });
  
          $.ajax({
              type: "POST",
              url: "/Customers/SaveCustomer",
              data: data,
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(result) {
  
                  location.reload();
                  alert(result);
              },
              error: function (result) {
                  alert(result+" Error!");
              }
          });
  
  
      });
  });
  </code></pre>
  
  <p>dapper insert code</p>
  
  <pre><code>      [HttpPost]
        public ActionResult SaveCustomer(newCustomers customers,int _id=0)
        {
  
           var result = "Error! Customers Required Details Have Not Been Entered!";
            if (_id == 0)
            {
  
                   DapperOrm.ExcuteToSave("sp_CustomerInsertNew", new 
          DynamicParameters(new
                  {
                      //custType = customers.customerType == null ? "credit" : 
          customers.customerType,
                      customertype = customers.customertype == null ? 1 : 
           customers.customertype,
                      pricetype = customers.pricetype == "" ? "retail" : 
           customers.pricetype,
                      customername = customers.customername,
                      idnumber = customers.idnumber,
                      contact = customers.contact,
                      location = customers.location,
                      loyaltycard = customers.loyaltycard,
                      creditlimit = customers.creditlimit == null ? 0 : 
       customers.creditlimit,
                      remainingcredit = customers.creditlimit == null ? 0 : 
       customers.creditlimit
                     }));
  
  
            }
         return Json(result, JsonRequestBehavior.AllowGet);
  </code></pre>