php - jquery ajax get json array? -


I use $ .getJSON to call php file. It takes it back. <$ } echo "{'Result': 'Error', 'Count': '$ nr'}"; To get results, use

I just

alert (data.result) in jquery

How do I get all the nr: s in counting is ?

Edit: But how do I array in jquery through array? All the keys are numerical and I do not know about retrieving them.

Use a JSON array to convert your PHP array:

  resonance "{'result': 'error', 'count':" .json_encode ($ nr). "}";  

You can also create your own hole response message with PHP types and then convert it to json_encode :

  $ response = array ('result' = & gt; 'error', 'calculation' => array ()); ($ I = 0; $ i & lt; = 10; $ i ++) {$ response ['calculation'] [] = $ i; } Echo json_encode ($ response);  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -