Editor Ajax URL with Parameters

Editor Ajax URL with Parameters

stronglightsmartstronglightsmart Posts: 1Questions: 1Answers: 0

We freshly purchased Editor, but we are bloody beginners, maybe somebody have a hint for us.

We are using Scripts made by the editor generator, wich works very good. But in one script we try to pass a Parameter via ajax, which ist failing.

Our script receive datas without any problems as long as we pass URL like:

ajax: "php/table.tbl_prices.php",

But if we try to pass an URL with Parameter for a WHERE-Condition like
ajax: "php/table.tbl_prices.php?project_id=2",

our script do not receive any data.
If we run the "table.tbl_prices.php?project_id=2"-Script directly, it will return Data like:
{"data":[{"DT_RowId":"row_235","project_id":"31","price_group":"A","price":"3555.00"}......
So the script table.tbl_prices.php can handle the parameter.

How we pass the parameter correctly?

More easy would be, if we could pass the WHERE-condition directly from my script like:

var editor = new $.fn.dataTable.Editor( {
where: ['project_id', <?php echo $project_id; ?>),
ajax: "php/table.tbl_prices.php?project_id=2",
table: '#tbl_prices'.....

But I think this in not possible. Is there another way to pass variables to table.tbl_prices.php?

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    ajax: "php/table.tbl_prices.php?project_id=2",

    That looks fine to me. How are you trying to use the variable? Something like this should do:

    ->where( 'project_id', $_GET['project_id'] )
    

    Allan

This discussion has been closed.