AJAX call from a column
AJAX call from a column

Hello
I have an Editor DT and i would like to do an ajax call on a specific column.
For example, if i have the employee number entered in the cell, i would like to do an ajax call to verify that employee id in the database and display his name.
Do i need to implement this ajax call in the editor.on( 'close') event ? If it is so then i will need to identify in this event where i'm located (cell) ...
I don't want to do any server-side processing, just a regular ajax call returning the information i need :
$.ajax( {
url:"/path_to_ajax/my_ajax_program.php",
cache: false,
async: false,
data:'query=' + employee_id,
dataType:"json",
type:"POST",
success: function(data){
var dataLen = data.length;
<...>
}
}
);
Is this possible with the DT Editor ?
Of course, as usual, if you have any example that will be welcome.
Thanks again for your great help via here
x1484
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
Hi @x14841003 ,
You can use
dependent()
for that - there's an example on that page of doing an Ajax request.Cheers,
Colin
Hi Colin
As usual, >> THANKS A LOT ! <<... i could make it working and again you helped me.
One latest question related to the DT Editor cell content.
I'm using a lot of typeahead.js (https://github.com/bassjobsen/Bootstrap-3-Typeahead)
Is it possible inside a cell to make an ajax call (so external php to get the rows from the database) as for a regular typeahead ? any example would be appreciated !
Thanks again !
x1484
Hi @x14841003 ,
I guess you could have
keyup
event listener on theinput
element that issues the Ajax call. I don't know anything about typeahead I'm afraid, so can't offer anything there.Cheers,
Colin
Hi Colin
OK thanks, i will have a look at this one.
Cheers
x1484