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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -