最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp localize script - How to make tabulator ajax call in wordpress?

programmeradmin5浏览0评论

As per tabulator documentation the ajax request can be made using the format like this

Ajax documentiation : .5/data#ajax

  var table = new Tabulator("#example-table", {
  ajaxURL:aglAjax.ajax_url,
  ajaxParams:{tabledata:aglAjax.data},
  ajaxConfig:{
        method: 'GET',
        mode:"cors", //set request mode to cors
        credentials: "same-origin", //send cookies with the request from the matching origin
         headers: {
             "Accept": "application/json", //tell the server we need JSON back
             "X-Requested-With": "XMLHttpRequest", //fix to help some frameworks respond correctly to request
             "Content-type": 'application/json; charset=utf-8', //set the character encoding of the request            
        },
  },
ajaxResponse:function(url, params, response){
        //url - the URL of the request
        //params - the parameters passed with the request
        //response - the JSON object returned in the body of the response.
        alert("Response Recived");
        console.log(response);
        return response; //pass the data array into Tabulator
    },
});

I am passing the data using localize script and tested if the data is passed. I am able to pass the variables, they show up correctly but I get 400 error every time ..not sure where I am making the mistake..can't tabulator ajax method be used in WordPress?

发布评论

评论列表(0)

  1. 暂无评论