Difference between $.get and $.Ajax Get request

Both get data from server using HTTP request. But $.Ajax has more control and $.get is a shorthand of $.Ajax.So if you simply want to do simple stuff use $.get.

$.Ajax

jQuery.ajax({
url: ‘test.txt’,
dataType: ‘text’,
type: “GET”,
success: function(data) {
console.log(data);
}
});

$.get

jQuery.get(‘test.txt’,function(data){
console.log(data)
},’text’);

Leave a comment