PHP json_encode and jQuery parseJSON not working -


i'm attempting pass array php jquery.

php file. $results array

echo htmlspecialchars(json_encode($results)); 

jquery

jquery.post(url, data, function(response) {                          var discount_obj = json.parse(response);                         var discount_type = "";                         var discount_amount = "";                          $.each(discount_obj,function(index,item) {                             if(index=="discount_type") {                                 discount_type = item;                             }                              if(index=="value") {                                 discount_amount = item;                             }                          }); }); 

i keep getting error uncaught syntaxerror: unexpected token &.

here json returned

[      {         "id":"4",       "code":"test_code_3",       "description":"<p>testing4<\/p>",       "value":"100",       "type":"discount",       "username":"mark",       "valid_from":"09\/01\/2015",       "expires":"10\/23\/2015"    } ] 

how solve?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -