I am using Tabulator 4.6, and I have an API with POST method, and I want to fetch tabulator data through a POST request, not GET.
In my org.js is like:
var ajaxConfig = {
mode: "no-cors",
method: "POST", //set request type to Position
headers: {
"Content-type": 'application/json; charset=utf-8',
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),
"Access-Control-Allow-Origin": '*'
},
var ajaxParams = { key1: "value1", key2: "value2"};
var ajaxURL = "https://rest.com/api/listrobot";
function queryRealm(url, config, params) {
return new Promise(function (resolve, reject) {
$.ajax({
url: ajaxURL,
success: function (data) {
//do some async data retrieval then pass the array of row data back into Tabulator
//resolve(JSON.parse(data));
resolve(data);
},
error: function (error) {
//if there is an error call this function and pass the error message or object into it
reject(error);
}
})
});
}
My backend API URL "https://rest.com/api/listrobot" is returning JSON data, and I have tried with postman also.
In org.js(tabulator), when I tried using the GET method to fetch data, it works well when I changed it to POST accordingly API also it is not working.
Route::post('/listrobot',[OrgrobotController::class,'ReadRobot'])->name('list_robot');
I tried this URL with org.js(tabulator) throws Ajax load error statusText: "Method Not Allowed"
You can change the request method to POST using the ajaxConfig option
var table = new Tabulator("#example-table", {
ajaxURL:"http://www.getmydata.com/now", //ajax URL
ajaxConfig:"POST", //ajax HTTP request type
});