Answers for "jquery ajax get data"

7

jquery ajax get

$.ajax({
    	url: "www.site.com/page",
    	success: function(data){ 
    	    $('#data').text(data);
    	},
    	error: function(){
    		alert("There was an error.");
    	}
    });
Posted by: Guest on March-28-2020
3

ajax data post call in javascript

$.ajax({
   url: 'ajaxfile.php',
   type: 'post',
   data: {name:'yogesh',salary: 35000,email: '[email protected]'},
   success: function(response){

   }
});
Posted by: Guest on October-27-2020
0

make ajax request post jquery

$.ajax({
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})
Posted by: Guest on July-21-2020
0

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
Posted by: Guest on June-18-2021
2

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);
    }
};
Posted by: Guest on April-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language