locked
.Net Core 3.0 MVC app | Unable to receive response to the client from APIController RRS feed

  • Question

  • User-954742055 posted

    Appreciate if you can help me with this issues, it could be minot but am unable to crack it.

    Problem,

    Although API is being called but there is NO response coming back to the browser. Status is showing as cancelled in network tab under chrome devtools, any idea what's happing here? I am unable to crack this out

    My code details -

    In my _layout file I am using following CDN scripts at the last just before today tag closing and Jquery CDN in html tag,

    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous" async></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous" async></script>

     have a API controller, listed as below

    I have a api controller, listed as below

    And this is how am calling above api through Jquery from one of the View

    And Startup.cs look like below,

    Saturday, August 22, 2020 11:07 AM

All replies

  • User753101303 posted

    Hi,

    AFAIK requests are cancelled when the Ajax request happens while the page is being unloaded. What is SendData? Could it be a submit button?

    Saturday, August 22, 2020 12:18 PM
  • User-954742055 posted

    Hi,

    AFAIK requests are cancelled when the Ajax request happens while the page is being unloaded. What is SendData? Could it be a submit button?

    Thank you for response, really appreciate your time replying for my issue.

    Yes, Senddata is an button. So when user clicks on the button, I am implementing in it's "onclick "event"

    Saturday, August 22, 2020 12:21 PM
  • User-474980206 posted

    But are you canceling the form submit? If it’s a button be sure to make a non submit button. Submit is the default.

       <button type=“button”>click will not post back</button>

    Or you can cancel the click event. Add the event parameter to the event handler and cancel

      e.preventDefault();

    see https://api.jquery.com/event.preventDefault/

    Saturday, August 22, 2020 2:45 PM
  • User-954742055 posted

    But are you canceling the form submit? If it’s a button be sure to make a non submit button. Submit is the default.

       <button type=“button”>click will not post back</button>

    Or you can cancel the click event. Add the event parameter to the event handler and cancel

      e.preventDefault();

    see https://api.jquery.com/event.preventDefault/

    Bruce, 

    It worked, thank you so much for highlighting it. Totally overlooked such minor item. My knowledge is fading..

    Saturday, August 22, 2020 3:19 PM