title: Promise Error When Ajax Call an Action Method
body: <p>Many of tables in my database consist of column named: fldValid, fldApproved, fldFinalized,... which has similar meaning in all tables.
  For reducing code lines I try to use a common method and function in my application as mentioned below:</p>
  <p>In each view of my application, a JS function defined as follow to call another JS function which is defined in Scripts section of main layout of application and is accessible for all views of application:</p>
  <pre><code>function tblDailyReportApproved(id) {
      try {
          let status = $(&quot;#colApproved&quot; + id).attr(&quot;data-approved&quot;).toLowerCase();
          SetApproved(&quot;@(typeof(cesEntities.Models.cesProjec  t.tblDailyReport).FullName)&quot;, id, status).then(function (result) {
              if (result == true) {
                  if (status.toLowerCase() == &quot;true&quot;) {
                      $(&quot;#colApproved&quot; + id).attr(&quot;data-approved&quot;, &quot;false&quot;);
                      $(&quot;#colApproved&quot; + id).append('&lt;i class=&quot;bi bi-check&quot;&gt;&lt;/i&gt;');
                  } else {
                      $(&quot;#colApproved&quot; + id).attr(&quot;data-approved&quot;, &quot;true&quot;);
                      $(&quot;#colApproved&quot; + id).html(null);
                  }
              } else {
                  swalError.fire({text:result.message});
              }
          });
      } catch (e) {
          swalError.fire({ text: e.message });
      }
  }
  </code></pre>
  <p>Above function call SetApproved function which is defined in layout and code implemented as follow:</p>
  <pre><code>function SetApproved(entityFullName, id, status) {
      return new Promise(function (resolve, reject) {
          $.ajax({
              type: &quot;GET&quot;,
              url: &quot;/Common/SetApproved&quot;,
              data: {
                  &quot;entityFullName&quot;: entityFullName,
                  &quot;id&quot;: id,
                  &quot;status&quot;: status
              },
              headers: { &quot;XSRF-TOKEN&quot;: $('input:hidden[name=&quot;__RequestVerificationToken&quot;]').val() },
              success: function (result) {
                  resolve(result);
              },
              error: function (err) {
                  reject(err); // Reject the promise and go to catch()
              }
          });
      });
  }
  </code></pre>
  <p>Finally above function call action method with name of SetApproved and C# code implemented as follow:</p>
  <pre><code>public IActionResult SetApproved(string entityFullName, int id, bool status)
  {
      Type entityType = GetEntity(entityFullName);
      if (entityType == null) return new JsonResult(new { status = false, message = &quot;Invalid data&quot; });
   
      try
      {
          bool result = db.CommonRepository.SetApproved(entityType, id, status);
   
          if (!result)
              return new JsonResult(new { status = false, message = &quot;Operaion not done&quot; });
   
          if (db.SaveChangesByUserId(HttpContext.Session.GetActiveUser_UserId()) == 0)
              return new JsonResult(new { status = false, message = &quot;Operaion not saved&quot; });
   
          return new JsonResult(result);
      }
      catch (Exception ex)
      {
          return new JsonResult(new { status = false, message = ex.Message });
      }
  }
  </code></pre>
  <p>These implementation worked already but now when client click on button, following error appear:
  <a href="https://i.stack.imgur.com/SOskC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SOskC.png" alt="enter image description here" /></a></p>
  <p>Please help me to solve and find the error reason.
  Thank you all</p>