update input content in editor when another change

update input content in editor when another change

Bob76Bob76 Posts: 3Questions: 1Answers: 0

Sorry... question was not posted in the correct discussion

Hello
I try to update a select content in editor when another select change event occurs.

$('select', editor.field('documents.Operation').node()).change(function() {
    $.ajax ({
        url: 'ajax_lots.php',
        method: 'GET',
        data: {OpID: editor.field('documents.Operation').val()},
        dataType: 'json',
        success: function ( data ) {
            editor.field('documents.Lot').update( data )
        }
    })
})
 
 
ajax_lots.php :
 
 
<?php
include( "../lib/DataTables.php" );
 
    if(isset($_GET['OpID'])) $filter = $_GET['OpID'];
    $Sql="(SELECT '' as 'value', '' as 'label') UNION (";
    $Sql.="SELECT DISTINCT  `ID` as 'value', `Numero` as 'label' FROM  `lots` ";
    if($filter) $Sql.= "WHERE `Operation` ='".$filter."'";
    $Sql.= " ORDER BY `Numero`) ";
    $data = $db
            ->sql($Sql)
            ->fetchAll();

when change event occurs, the php is launched
if I var_dump $data,at the end of php file called, the values are correct

But I never can get the value returned (XHR tell 'this request has no response avalaible') outside the php file.

I do not understand why...

Is fetchAll() the correct way to set the values?

Please help

Replies

  • allanallan Posts: 52,497Questions: 1Answers: 8,012 Site admin

    I looks like you might be missing one thing only - returning the data from the PHP script. Try adding:

    echo json_encode( $data );
    

    Allan

  • Bob76Bob76 Posts: 3Questions: 1Answers: 0

    Hi allan

    Just one line and all is better...

    I feel so alone when searching up to 2 days where was the issue...

    Thanks a lot

  • allanallan Posts: 52,497Questions: 1Answers: 8,012 Site admin

    Heh - we've all been there. Welcome to the club ;).

    Allan

Sign In or Register to comment.