Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery $.ajax()

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 285
    Comment on it

    $,ajax() allows to make an ajax call.

    This method provide more control than any other method.

    In the ex below all the parameters  and comment related to each parameter describe the purpose of each one.

    var ajaxUrl = "Json.htm";
                $("#btnAjax").click(function () {
                    $("#dvAjax").html(ajax_load);
    
    
                    $.ajax({
                        type: "GET", 		//GET or POST or PUT or DELETE verb
                        url: ajaxUrl, 		// Location of the service
                        data: "", 		//Data sent to server
                        contentType: "",		// content type sent to server
                        dataType: "json", 	//Expected data format from server
                        processdata: true, 	//True or False
                        success: function (json) {//On Successful service call
                            var result = json.name;
                            $("#dvAjax").html(result);
                        },
                        error: ServiceFailed	// When Service call fails
                    });
    
                    return false;
                });

    Important

    It provide more control on data sending and response.

    It allows to handle error occur during call.

    It allows to handle data if the call to the page is successful.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: