change select content after another select changed in editor

change select content after another select changed in editor

Bob76Bob76 Posts: 3Questions: 1Answers: 0

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

Answers

This discussion has been closed.