jQuery AJAX

How jQuery AJAX Methods works…

AJAX is the technic of exchanging data with a server and updating parts of a web page — without reloading the whole page.

Example of $.ajax():

$.ajax({type : “POST”, url : “example.txt”, dataType: “xml/html/text/script/json”,success : function(data){console.log(data);},error : function(res) {console.log(JSON.stringify(res));}});

Excample of $.get():

Syntax — $.get(URL,data,function(data,status),dataType)

$.get(“demo_test.asp”, function(data, status){alert(“Data: “ + data + “\nStatus: “ + status);});

Example of $.post():

$.post(URL,data,function(data,status),dataType)

var txt = $(“input”).val();$.post(“demo_ajax_gethint.asp”, {suggest: txt}, function(result){$(“span”).html(result);});

Other Methods:

Serialize(), serializeArray()

--

--