how can i remove the auto-attached parameter "_" when getting data using server-side proccessing

how can i remove the auto-attached parameter "_" when getting data using server-side proccessing

johnchengjohncheng Posts: 3Questions: 1Answers: 0

Hi,
I am using sAjaxSource to get data from server side, and am using fnServerParams to customize my parameters, which the code looks like this:
var dd = $('#form-table').DataTable({
"destroy": true,
'sAjaxSource': "/form/load_fields/",
'fnServerParams': function ( aoData ) {
aoData.push( { "name": "id", "value": "{{$form->id}}" } );
},
});

i need to match the router rules for some reason, actually, the sAjaxSource points to an MVC controller action, which, need and only need one parameter, 'id'. However, when the ajax event triggers, i can see there is always a parameter "" at the end of the ajax url, something like "http://localhost/form/load_fields/?id=29&_=1402540233777", i dont want that ""parameter, but i can't find how to remove it out

anyone can help?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    It is the jQuery anti-cache parameter. Add cache: true to your ajax object to remove it.

    Allan

  • johnchengjohncheng Posts: 3Questions: 1Answers: 0

    ah, it's working. thank you allan. BTW, is there a way to change the ajax url into clean format like "http://localhost/form/load_fields/29"? i've search the documentation but couldnot find one.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    You would just specify the URL to load as that which you want. DataTables (nor jQuery) will convert your URL from one form to another.

    Allan

  • johnchengjohncheng Posts: 3Questions: 1Answers: 0

    yeah, that's it, thank you Allan and the great plugin

This discussion has been closed.