I want to add querystring parameters when deleteurl is called.

I want to add querystring parameters when deleteurl is called.

lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
edited July 2011 in General
How to add query string parameters after i get the row data and i want to append the row data as query string in the delete Url.
This is the code i am using.

$(document).ready(function()
{
var oTable;
oTable=$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php echo base_url(); ?>Test/Listener",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "more_data", "value": "my_value" } );
//alert('Taha Hasan');
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
alert('Taha Hasan');
fnCallback(json)
} );
}

} ).makeEditable({
sUpdateURL: "<?php echo base_url(); ?>Test\UpdateData?id=",
sAddURL: "AddData.php",
sAddHttpMethod: "GET",
sDeleteURL: "<?php echo base_url(); ?>Test/DeleteData",
sDeleteHttpMethod: "GET",
});

$('#example tbody tr').live('click', function (event) {
var aData = oTable.fnGetData(this); // get datarow
if (null != aData) // null if we clicked on title row
{
//now aData[0] - 1st column(count_id), aData[1] -2nd, etc.
var str1=aData[0];
var str2="&type=fitment";
queryString=str1.concat(str2);
}
}
);

}


);
Question:
The above code ,when i click on delete button,hits the Delete URL with its own appended url Test/DeleteData?id=firstcoumncelldata....how can i modify this URL at runtime by adding my own query string rather than automatically generated one ???

Replies

  • lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
    Plz help me on this.I am waiting for reply.It seems to be a basic problem.I have searched on forums and haven't found the solution yet :S
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited July 2011
    I don't think you can. I toyed around with it and it only seems to send a single parameter "id".

    You can add some parameters to the url string, but they'll be static - nothing you can change at run-time based on whatever's going on.. it's set at initialization time.
    [code]
    "sDeleteURL": "del.php?a=hi&b="+(new Date()).toLocaleTimeString(),
    [/code]

    it's not too hard to write your own routine, call $.ajax() to your delete script with whatever params you want. attach to whichever button or element you want: http://api.jquery.com/jQuery.ajax/
    [code]
    function delete_id(database_id) {
    $.ajax({
    async: false, // only if you want this ajax call to NOT be asynchronous
    url: "delete.php",
    data: {
    a: "hi",
    b: (new Date()).toLocaleTimeString(),
    id: database_id
    }
    success: function(data, textStatus, jqXHR) {
    // clean-up code can go here, especially if you're running asynchronously
    }

    }

    // clean-up code you want after, like refreshing the table, if you're runing synchronously
    oTable.fnDraw();
    }
    [/code]

    you can also specify error callbacks, etc.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    In this forum post, someone mentions an oDeleteParameters object...

    http://www.datatables.net/forums/discussion/5807/allowing-addition-form-params-to-be-submitted-with-an-update-call
  • lordoffriendslordoffriends Posts: 14Questions: 2Answers: 0
    Thanks buddy :)
This discussion has been closed.