logo image

Ajax calls using JQuery

42


Simple GET Call

$.ajax({
		url: '/api/endpoint/',
		complete : function(data){
		console.log('Status Code:' + data.status);
		console.log('Response:' + data.responseText);
	}
});

Simple POST Call with application/json content type

$.ajax({
		url: '/api/endpoint/',
		type: "POST",
		data: JSON.stringify(content),
		contentType: 'application/json',
		dataType: 'json',
		complete : function(data){
		console.log('Status Code:' + data.status);
		console.log('Response:' + data.responseText);
	}
});