AJAX call from a column

AJAX call from a column

x14841003x14841003 Posts: 33Questions: 9Answers: 0
edited October 2019 in Free community support

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

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @x14841003 ,

    You can use dependent() for that - there's an example on that page of doing an Ajax request.

    Cheers,

    Colin

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0
    edited October 2019

    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

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @x14841003 ,

    I guess you could have keyup event listener on the input element that issues the Ajax call. I don't know anything about typeahead I'm afraid, so can't offer anything there.

    Cheers,

    Colin

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hi Colin

    OK thanks, i will have a look at this one.

    Cheers
    x1484

This discussion has been closed.