Can i call Mulitple ajax in one method when i am post data then get automatically.
Loading
Can i call Mulitple ajax in one method when i am post data then get automatically.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question.
Brahma Prakash ShuklaPosted Nov 1, 2023, 12:55 PM
Yes, you can make multiple AJAX (Asynchronous JavaScript and XML) requests within a single method, and you can set them up to be executed sequentially or concurrently, depending on your requirements.
Here's a basic example of how you can make multiple AJAX requests using JavaScript and jQuery:
In this example, the first AJAX request is a POST request, and the second one is a GET request. You can nest these requests if you want them to be executed sequentially. However, if you need to make the requests concurrently, you can use
$.ajaxor$.getor$.postmethods to create multiple requests and then usePromise.allor other mechanisms to handle their responses asynchronously.Here's an example using
Promise.allto execute multiple requests concurrently:This will send both requests simultaneously and handle their responses when they are ready. You can extend this pattern to make more requests as needed.