How do you combine a Normal Ajax(post) call with Datatables function.

How do you combine a Normal Ajax(post) call with Datatables function.

belsarerohit81belsarerohit81 Posts: 6Questions: 4Answers: 0
edited July 2015 in Free community support
                     var sendData=$("#target").seralize();                //Serializing Form element values
        var oTable = $('#example').dataTable({
                "bJQueryUI": true,
                    "bProcessing": true,
                "bServerSide": false,
                "ajax": {
                                    "url": "query.cfm",
                                    "type":"post",
                                "data": sendData 

// I am not able to send this "sendData" variable across to the url hence datatables do not load and once I remove this variable the datatables work just fine.

                    },
                "aoColumns": [

This question has an accepted answers - jump to answer

Answers

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16
    edited July 2015

    Hi belsarehit81,

    The ajax.data property can be used as a function like so:

    "data": function(d) {
        d.form = $("#target").seralize();
    }
    

    Hope this helps,

  • belsarerohit81belsarerohit81 Posts: 6Questions: 4Answers: 0

    Thanks for the Reply.
    How will I access these Variables on server side?

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16

    They should be accessible like any other form post data.

    e.g. if you named your custom property extra_data then that should be available from the form variables on the server Params["extra_data"].

    Just to give you a generic example since I am unfamiliar with anything other than .NET/C#.

  • belsarerohit81belsarerohit81 Posts: 6Questions: 4Answers: 0
    edited July 2015

    Yes.
    True we can access the variables just like any other form post data.

    I am using Coldfusion.
    i was able to work this out by a slit change in your code.

    "data": function(d) {
    returns $("#target").serialize();
    }

    Working fine now!

    Thanks Ashbjorn !

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16
    Answer ✓

    Always happy to help, glad to know my information has led to a solution.

This discussion has been closed.