Data parameter for Ajax source

Data parameter for Ajax source

cdelgadillocdelgadillo Posts: 2Questions: 1Answers: 0
edited September 2022 in Free community support

I want to use Datatables in wordpress to manage information in MySQL in a cloud server. I have a PHP function in the cloud server that receives a parameter in the data parameter of the POST function in Ajax (actually, I am using jQuery.Post). But I cannot found any way to fill the parameter. One option would be to call the post function, and then use the result to create the table, but is not working (I do not get any errors, but no data is loaded although I have athe data already in the javascript variable), maybe because I would use javascript array as a source, but I suppose I need to set processing and serverside. ¿Is any way to set the data parameter of Ajax POST? ¿Or a way to do server processing but having the data from another source? Thanks

This is the javascript using a previous Ajax call

jQuery(document).ready(function() {
    var dataSet;
    var r = jQuery.post("/wp-includes/fnbdatos.php", 
            {"funcion":"execQMultA", "param1":"select pais, nom_pais, nom_corto_pais, continente from Paises "},
            function(d) {
                dataSet = d;
             });

     jQuery('paises').DataTable({   
        ajax: {
            processing: true,
            serverSide: true,
            dataSrc: dataSet
        }
    });
});

This is the javascript using only ajax in DataTable, but no place to send the SQL Query

jQuery(document).ready(function() {
        jQuery('paises').DataTable({    
        ajax: {
            url: "/wp-includes/fnbdatos.php",
            processing: true,
            serverSide: true,
            dataSrc: "datos"
        }
    });
});

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.