Use an array in an AJAX jquery function from json-encode();
Hi, I'm new to AJAX
I have un page where i want to call an ajax request to add something on this page. export.php
<div class="row">
    <div class="span12">
        <select id="listTable" name="listTable">
            <option value="appel">Appels</option>
            <option value="dossier">Dossiers</option>
            <option value="commande">Commandes Fournisseur</option>
         </select>
    </div>
</div>
<div class="row">
    <div class="span12">
         <button class="btn btn-primary" onClick="selectTable()">Select</button>
    </div>
</div>
<div id ="columns" class="row" style="display:none;">
    <div class="span12">
         <div id="columns-check" style="">
            <!-- Here will be displayed the content of the ajax request-->
         </div>
    </div>
</div>
<script type="text/javascript" src="_module/ExportFichier/exportFile/ajax/requestExport.js"></script>
Here's my ajax function
function selectTable(table){
    var table = $("#listTable").val();
        $.ajax({
            url: "_module/ExportFichier/exportFile/ajax/requestColumns.php",
            type: "POST",
            data: "table="+table,
            dataType: 'json',
            success: function(data){
                $('#columns').css('display','block');
                $('#columns-check').empty();
                for(i=0; i<data; i++){
                    $('#columns-check').prepend('<div>I would like to display here the content of my array</div>');
                }
            },
            error: function(){
                alert('The Ajax request did not works!');
            }
        });
}
requestColumns.php
header("content-type: application/json; charset=utf-8");
require_once '../requirements.php';
$tableName = $_POST["table"];
$objService = new ExportFileService($tableName);
$columns = $objService->get_columns();
echo json_encode($columns);
I didn't get the way I can return an array from my requestColumns.php file to my jquery Ajax request and after use it to modify the DOM of my page export.php. Thanks for your help.
 
     
     
    