jquery ajax methi code example
Example: jquery ajax syntax
$.ajax({
url: "post.php",
data: {
id: 123
},
type: "GET",
dataType : "json",
})
.done(function( json ) {
$( "<h1>" ).text( json.title ).appendTo( "body" );
$( "<div class=\"content\">").html( json.html ).appendTo( "body" );
})
.fail(function( xhr, status, errorThrown ) {
alert( "Sorry, there was a problem!" );
console.log( "Error: " + errorThrown );
console.log( "Status: " + status );
console.dir( xhr );
})
.always(function( xhr, status ) {
alert( "The request is complete!" );
});