Every 10 seconds, two ajax based methods are executed. However, when I submit the form for processing, it waits for the previous ajax calls to complete before processing. I want to prioritize the form submission.
Below is the script that I am using:
function refresh_ss_one(){
$.ajax({
type: 'GET',
url: "{{ route('RefreshSessionOne') }}",
data: {},
success: function(response){
console.log(response);
}
});
}
function refresh_ss_two(){
$.ajax({
type: 'GET',
url: "{{ route('RefreshSessionTwo') }}",
data: {},
success: function(response){
console.log(response);
}
});
}
setInterval(refresh_ss_one, 10000);
setInterval(refresh_ss_two, 10000);
I have another method that should run on form submission event and needs to be prioritized. Despite using the async
parameter in my ajax function, the issue persists.
$("#check-rate").submit(function(e) {
var form_data = $(this);
$.ajax({
type: 'POST',
url: currency_route,
data: form_data.serialize(),
success: function(response)
{
...
}
});
e.preventDefault();
});
I am looking for guidance on how to resolve this issue...