Help solve the dilemma: trying to output data from the database on Ajax. JSON data array is formed, but I do not see any data on the page. Help me find a joint. Code:
<script type="text/javascript"> $(document).ready (function previuLoad (){ $.ajax ({ type: "POST", url: "php/previuLoad.php", dataType: "json", success: function (data){ $('#smenu').html(data); } }); }); </script> <div id="smenu"></div> <?php include 'db.php'; mysql_query("set names 'utf8'"); $result = array(); $res = mysql_query ("SELECT title,link FROM foot", $db); $arp = mysql_fetch_assos ($res); while ($arp = mysql_fetch_assos ($res)){ $result[] = $arp } echo json_encode ($result); ?> The array in the database has the form: (id: 1.2.3.et.d. title: title1. Title2.title3, etc.) and in that spirit.
I have a suggestion that I incorrectly refer to a multidimensional array. What should the query syntax look like, for example, the third Title record: data.2.title? Or I'm wrong?
$result[] = $arpnot enough semicolon. - etki