php - Use an array in AJAX jquery -
php - Use an array in AJAX jquery -
use array in ajax jquery function json-encode();
hi, i'm new ajax
i have united nations page want phone call ajax request add together on 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 displayed content of ajax request--> </div> </div> </div> <script type="text/javascript" src="_module/exportfichier/exportfile/ajax/requestexport.js"></script>
here's 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 display here content of 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 way can homecoming array requestcolumns.php file jquery ajax request , after utilize modify dom of page export.php. help.
maby help? jquery json
it become this:
for (var in data.<your_key>) { $('#columns-check').prepend('line: ' + data.<your_key>[i]); }
php jquery ajax json
Comments
Post a Comment