jquery ajax get
$.ajax({
url: "www.site.com/page",
success: function(data){
$('#data').text(data);
},
error: function(){
alert("There was an error.");
}
});
jquery ajax get
$.ajax({
url: "www.site.com/page",
success: function(data){
$('#data').text(data);
},
error: function(){
alert("There was an error.");
}
});
ajax data post call in javascript
$.ajax({
url: 'ajaxfile.php',
type: 'post',
data: {name:'yogesh',salary: 35000,email: '[email protected]'},
success: function(response){
}
});
make ajax request post jquery
$.ajax({
method: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
jquery datatable ajax get data
DataTables Example Using an Ajax Callback
The DataTables ajax option, here is a common way to retrieve
dynamic data from a source, for loading into a table.
$('#example').dataTable( {
"ajax": {
"url": "https://myurl.goeshere.com/mydata",
"type": "POST",
"dataSrc": "my_data"
}
} );
However, you can also use a function with the DataTables ajax option,
instead of an object. Here is an example:
$(document).ready(function() {
var table = $('#demo').DataTable( {
ajax: function (data, callback, settings) {
$.ajax({
url: "http://localhost:7000/ajax-employee-objects",
}).then ( function( json, textStatus, jqXHR ) {
json["data"] = json["row_objects"];
delete json["row_objects"];
//console.log(textStatus); // "success"
//console.log(json.extra_data.foo); // "bar"
callback(json);
});
},
columns: [
{ data: "name" },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: "start_date" },
{ data: "salary" }
]
});
} );
Github NathanNoSudo
ajax get js
let xhr = new XMLHttpRequest();
xhr.open("GET", "une/url");
xhr.responseType = "json";
xhr.send();
xhr.onload = function(){
if (xhr.status != 200){
alert("Erreur " + xhr.status + " : " + xhr.statusText);
}else{
alert(xhr.response.length + " octets téléchargés\n" + JSON.stringify(xhr.response));
}
};
xhr.onerror = function(){
alert("La requête a échoué");
};
xhr.onprogress = function(event){
if (event.lengthComputable){
alert(event.loaded + " octets reçus sur un total de " + event.total);
}
};
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us