Saturday, 15 March 2014

php - unable to detect "unexpected identifier" in parseJSON -


I am trying to get data of data from database and json_encode

  $ Data = json_encode ($ result);  

I've put an echo ($ data); Die (); I received the following result

  [{"CAL_DATE": "01-Jun-13", "CUSTOMER_TEXT": "or", "PRODUCT_GROUP": "ACP ',' 'NET_SALES' ' : "CWS", "PRODUCT_GROUP": "ACP's", "NET_SALES": "127948.68": "187002.04", "rank": "1"}, {"CAL_DATE": "01 Jun -13", "CUSTOMER_TEXT" "" "" "," "", "" "", "" "," "", " "3"}, "CAL_DATE": "June 1-13," "CUSTOMER_TEXT": "car", "PRODUCT_GROUP": "ACP's", "NET_SALES": "65,320.42", "rank": "4" } "" "" "" "" "" "" "" Code>  

and in jquery code I can parse JSON $ data below Trying

  $ (function () {var data = new array (); Data = $ ParseJSON ('& lt; php $ resonate data;; & gt;'); // error coming here // other code goes here));  

I'm getting an error Unwanted syntax error: unexpected identifier data = $ .parseJSON ('

  [{"CAL_DATE") in the following output:? "G-1", "CUSTOMER_TEXT": " 

"", "PRODUCT", "CUSTOMER_TEXT" , "CUSTOMER_TEXT", "MCK", "Inc.", "ACP", "NET_SALES": "127948.68", "rank": "2"}, {"CAL_DATE": "June 1-13" PRODUCT_GROUP ":" ACP's "," NET_SALES ":" 81,079.29 "," rank ":" 3 "}, {" CAL_DATE ":" June 1-13 "," CUSTOMER_TEXT ":" "", "PRODUCT", "PRODUCT", "PRODUCT GROUP": "AGP", "PRODUCT", " ":" ACP's "" NET_SALES ":" 31977.95 "," rank ":" 5 "}] Anyone can please tell me why I find an error in that line Having been? Thanks in advance

This is a valid Jason, so you do not need to parse it:

  data = & lt ;? Php $ data echo; ? & Gt;  

I think you want to use it like this:

  $ (function () {var data = '& lt ;; Php echo $ data;; & gt; '; data = $; from SEEN (data); // error coming here // other code goes here));  

From the document:

Takes a well-formed JSON string As a result, check the JavaScript value returns

with the docs:

  var obj = jQuery.parseJSON ('{name}: "John"}'); // Results {"name": "John"} Warning (obj.name === "John");  

'{"name": "John"}' ' is a string that is in Jason format.


No comments:

Post a Comment