panjo
panjo

Reputation: 3515

using data table sAjaxSource with parameter

I want to send user inserted value as parameter inside JQuery data table sAjaxSource property. something like this

var UsersData = $('input[name="UserValue"]').val();

        $('#myTable').dataTable({
            "bServerSide": true,
            "sAjaxSource": "/Home/ProcessThis/UsersData",
            "aaSorting": [[1, 'desc']],
...

how to use this UsersData variable inside sAjaxSource, above sAjaxSource example doesnt work.

Upvotes: 1

Views: 1013

Answers (1)

Joe
Joe

Reputation: 82634

Like so I believe:

    var UsersData = $('input[name="UserValue"]').val();

    $('#myTable').dataTable({
        "bServerSide": true,
        "sAjaxSource": "/Home/ProcessThis/" + UsersData,
        "aaSorting": [[1, 'desc']],

I'm assuming you are used to PHP where you can insert variable name into string, but in JavaScript you have to concatenate.

Upvotes: 1

Related Questions