I want to make $.get() method synchronous in my function. In ajax aysnc : false helps me, now how do i do the same to to $.get()
va
Although already answered:
$.ajax({
method: 'GET',
async: false
});
I want to warn of you the following:
Javascript is build based on event-driven design. you could also fire an custom named event (with the data result in the event data) when the ajax/get call is complete and let the followup action listen to this event.
eg:
$(form).on('submit',function(){
var formEl = this;
$.get({...}).success(function(data){
var event = new Event('data-submitted');
event.data = data;
formEl.dispatchEvent(event);
})
});
$(form).on('data-submitted',function(event){
var data = event.data;
// you can handle the post ajax request event here.
});