87,997
社区成员




$.ajax({
type: "GET",
url: "http://www.baidu.com",
dataType:"html",
beforeSend: function(XMLHttpRequest){
$("#area").html("sending request...");
},
success: function(data, textStatus){
$("#ajax").html(data);
},
complete: function(XMLHttpRequest, textStatus){
$("#area").html("complete request...");
},
error: function(){
$("#area").html("error occurs...");
}
});
<div id="ajax">
<div id="area"></div>
$.get("www.baidu.com",function(data){
alert(data);
})
$.ajax({
url: 'http://fiddle.jshell.net/favicon.png',
beforeSend: function( xhr ) {
xhr.overrideMimeType( 'text/plain; charset=x-user-defined' );
},
success: function( data ) {
if (console && console.log){
console.log( 'Sample of data:', data.slice(0,100) );
}
}
});