jquery 常用的后台交互脚本集合
get
$.get( "ajax/test.html", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
$.get( "test.php", { name: "John", time: "2pm" } );
$.get( "test.php", { "choices[]": ["Jon", "Susan"] } );
$.get( "test.cgi", { name: "John", time: "2pm" } )
.done(function( data ) {
alert( "Data Loaded: " + data );
});
post
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
$.post( "ajax/test.html", function( data ) {
$( ".result" ).html( data );
});
var jqxhr = $.post( "example.php", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
jqxhr.always(function() {
alert( "second finished" );
});