Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I access the contents of this JSON encoded php array?
    primarykey
    data
    text
    <p>I've edited this question to reflect the answers below. </p> <p>The array $animation is returned encoded from another function and contains strings of URL's like index.html, index1.html etc..</p> <p>I generated animation using this function..</p> <pre><code>$select = "SELECT card_id, order_num FROM decks WHERE box_num=$box_num AND id=$userid ORDER BY order_num"; $result = mysqli_query($db, $select) or die("SQL Error 1: " . mysqli_error($db)); while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) { $animation[] = array( 'card_id' =&gt; $row['card_id'], 'order_num' =&gt; $row['order_num'], ); } return json_encode($animation); </code></pre> <p>The contents of $animation is </p> <blockquote> <p>"[{"card_id":"baby","order_num":"1"},{"card_id":"selectBaby","order_num":"2"},{"card_id":"bed","order_num":"3"},{"card_id":"selectBed","order_num":"4"},{"card_id":"book","order_num":"5"},{"card_id":"selectBook","order_num":"6"},{"card_id":"cup","order_num":"7"},{"card_id":"selectCup","order_num":"8"},{"card_id":"cupboard","order_num":"9"},{"card_id":"selectCupboard","order_num":"10"},{"card_id":"daddy","order_num":"11"},{"card_id":"selectDaddy","order_num":"12"},{"card_id":"eating","order_num":"13"},{"card_id":"mummy","order_num":"14"},{"card_id":"selectMummy","order_num":"15"},{"card_id":"plate","order_num":"16"},{"card_id":"selectPlate","order_num":"17"},{"card_id":"shoe","order_num":"18"},{"card_id":"selectShoe","order_num":"19"},{"card_id":"table","order_num":"20"},{"card_id":"selectTable","order_num":"21"},{"card_id":"walking","order_num":"22"},{"card_id":"selectWalking","order_num":"23"},{"card_id":"dogNose","order_num":"24"},{"card_id":"selectDogNose","order_num":"25"},{"card_id":"teddyEars","order_num":"26"},{"card_id":"selectTeddyEars","order_num":"27"},{"card_id":"ActivityOne","order_num":"28"},{"card_id":"ActivityTwo","order_num":"29"},{"card_id":"ActivityThree","order_num":"30"},{"card_id":"ActivityFour","order_num":"31"},{"card_id":"ActivityFive","order_num":"32"},{"card_id":"ActivitySix","order_num":"33"}]"</p> </blockquote> <p>then I try to pass it javascript.</p> <pre><code>var url = &lt;?php echo $animation; ?&gt;; alert(url); //check the for some data </code></pre> <p>The output of this code is </p> <blockquote> <p>Object object Object object Object object Object object Object object Object object</p> </blockquote> <p>The output I need is the card_id so I can pass it to the url eg: baby,bed,book etc</p> <p>url url url url </p> <p>I need the strings to do this..</p> <pre><code>$(document).ready(function() { var suffix = ".html"; $('#buffer').load('../Animations/' + url[0] + suffix); $('#buffer').trigger('create'); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload