jquery call api code example
Example 1: how to set json type jquery ajax
$.ajax({
type: "POST",
contentType: "application/json",
url: 'http://localhost:16329/Hello',
data: { name: 'norm' },
dataType: "json"
});
Example 2: jquery ajax get
$.ajax({
url: "www.site.com/page",
success: function(data){
$('#data').text(data);
},
error: function(){
alert("There was an error.");
}
});
Example 3: get request jquery
$.get( "ajax/test.html", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
Example 4: jquery ajax endpoint
$.ajax({
type:"GET/POST",
url: "target url",
data: "var1=" + data1,
success: function(msg){
$("#targethtml").html(msg)
},
error: function(errormsg){
console.log(errormsg)
}
});