I have 2 ajax call in 2 difference functions. I want to use .click to call these 2 functions . The func1 is inserting data in to database, then func2 is to retrieve the data
Three ways:
Call func2 on success of func1:
function func1() { $.ajax({ ... }).done(func2); }
Use Deferred API to call func2 when funky completes:
Deferred
e.preventDefault(); $.when(func1).then(func2);
Make func1 synchronous (not recommended):
function func1() { $.ajax({url: '', async: false}); }