Harman Harman - 3 months ago 13
jQuery Question

After first ajax request then run second one.. Now same time run both function

I have ajax functionality which run tow request same time. I want run these function not same time, After first success run second ajax request

jQuery.ajax({
type:'Post',
data : {'first':first},
url : 'abc.php',
success : function (returnHtml) {
jQuery(".xyz").html(returnHtml);
}

});

jQuery.ajax({
type:'Post',
data : {'first':first},
url : 'abc1.php',
success : function (returnHtml) {
jQuery(".xyz2").html(returnHtml);
}

});


How can do this

Answer

User async in jquery

jQuery.ajax({
    type:'Post',
    async : false,
    data : {'first':first},
    url : 'abc.php',
    success : function (returnHtml) {
        jQuery(".xyz").html(returnHtml);
    }

});

jQuery.ajax({
    type:'Post',
    async : false,
    data : {'first':first},
    url : 'abc1.php',
    success : function (returnHtml) {
        jQuery(".xyz2").html(returnHtml);
    }

});