-1

I have apply jQuery ajax function like this please help me how can i async false in this code

$.post(base_url+"search/questionBox/"+finalTopic+"/"+finalCountry+'/'+findSearchText+'/'+ID,function(data){
  if (data != "") {
     $(".lazy_loading_ul").append(data);
  }
});
Jaskaran
  • 188
  • 1
  • 1
  • 12

1 Answers1

4

$.post is shorthand for $.ajax with the method set to POST. So you might as well do this:

$.ajax({
    url: base_url+ 'search/questionBox/'+finalTopic+'/'+
                                          finalCountry+'/'+findSearchText+'/'+ID
    async: false,
    type: 'POST'
}).done(function(data){
    if(data){
        $(".lazy_loading_ul").append(data);
    }
});

Though I advise against async: false in the first place. As of jQuery 1.8, the async option is deprecated.

Don't use it because it defeats the purpose of using AJAX in the first place.

Johan
  • 35,120
  • 54
  • 178
  • 293