Answers for "using post method send data in datatable ajax"

3

send data in datatable ajax

$('#datatable').DataTable({
        order: [],
        responsive: true,
        autoWidth: false,
        processing: true,
        serverSide: true,
        ajax: {
            url: AJAX_URL,
            data(d) {
                d.parameter_name_1 = 'value';
              	d.parameter_name_2 = 'value';
            }
        },
        columns: [
          {
          ---}
        ]
});
Posted by: Guest on August-01-2020
2

javascript send post data with ajax

function makeRequest (method, url, data) {
  return new Promise(function (resolve, reject) {
    var xhr = new XMLHttpRequest();
    xhr.open(method, url);
    xhr.onload = function () {
      if (this.status >= 200 && this.status < 300) {
        resolve(xhr.response);
      } else {
        reject({
          status: this.status,
          statusText: xhr.statusText
        });
      }
    };
    xhr.onerror = function () {
      reject({
        status: this.status,
        statusText: xhr.statusText
      });
    };
    if(method=="POST" && data){
        xhr.send(data);
    }else{
        xhr.send();
    }
  });
}

//POST example
var data={"person":"john","balance":1.23};
makeRequest('POST', "https://www.codegrepper.com/endpoint.php?param1=yoyoma",data).then(function(data){
              var results=JSON.parse(data);
});
Posted by: Guest on August-02-2019

Code answers related to "using post method send data in datatable ajax"

Code answers related to "Javascript"

Browse Popular Code Answers by Language