Skip to content
Advertisement

POST and GET methods on the same button

I am currently learning asp.net core 3 and I can’t find any help regarding this issue that I have. I have a form that submits a value with a POST request. But I want the same button to have a GET request that populates another field with a .ajax / xmlhttprequest. But I want the POST method to be executed first and then the GET method. Is it possible to do it? I’ve tried doing it but I got stuck.

These are the methods inside my controller.

JavaScript

And this is my JS script

JavaScript

Advertisement

Answer

You can use the $.ajax ‘done’ chaining to complete the entire process:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement