$.ajax({
url: '/ajax/',
type: 'get',
async —false,
success:function(d){
console.log(d);
},
});
If you would like to know the implementation in jQuery, you can view the source at the following site.
http://james.padolsey.com/jquery/#v=1.10.2&fn=jQuery.ajax
To do the same thing simply, use XMLHttpRequest to:
var httpRequest=new XMLHttpRequest();
httpRequest.onreadystatechange=function(){
if(httpRequest.readyState==4&&httpRequest.status==200){
// success
console.log (httpRequest.responseText);
}
};
httpRequest.open('GET', '/ajax/', false);
httpRequest.send(null);
© 2024 OneMinuteCode. All rights reserved.