Ajax call as async

Hi i am using ajax first time

my i am using get method in Ajax

my code Ajax code is

$("#comboBox1").change(function() {
        var text2 = $(this).children(':selected').text();
        var value2 = $(this).val();
        alert(text2 + " = " + value2);
        document.getElementById("hid1").value = value2;

                    $.get('Check1',{hid1:value2},function(res){
             $('#block3').load("new1.jsp");
                    });

                    if($('#cb5').length){
            alert("Found");
            combo2=$('#cb5').html();
            alert(combo2);
        }else{
            alert("Not-found");
        }
});

i need to call as asynchronous so where to put async:true in my code.

I am first time use Ajax so i Dose not know.... if anyone help me...

Answers


async:true is default in jQuery framework

If you want manage by $.ajaxSetup() function, because $.get dose not provide the pass additional setting params,

$.ajax() will be better and more intuitive

OR

$.ajaxSetup({async:true}); to setup globally


The "load" function you are using is already performing an (asynchronous) Ajax call. You do not have to add anything. It is asynchronous by itself.

See here for some more information.

To execute code after the function returns you can use

    $('#block3').load("new1.jsp",function(responseTxt,statusTxt,xhr){
      if(statusTxt=="success")
        alert("Found");
      if(statusTxt=="error")
        alert("Error: "+xhr.status+": "+xhr.statusText);
    });

Need Your Help

How to get reference to current UITableViewCell

ios objective-c uitableview reuseidentifier

At my experiment I need to have reference to first UITableViewCell in tableView. By some action I need to set image and some other cell properties and to keep this state of this only cell even if the

Detach JPA objects with lazy initialized properties

hibernate orm jpa transactions lazy-loading

There are two JPA entities: User and Order with one-to-many relationship.