javascript - understanding about returing two object lists by json_encode when one object list is already in json format -


I am using Ajax to get the Facebook comments of a post, so that the following php function calls the AJAX call For data returns by json encoding echo json_encode (array ($ JsonData, $ arr2)); Die ();

But the content in $ JsonData is already in json format because I think that getting the data of those comments on the Facebook post using the server side graph API call in the php function And the first $ JsonData has been assigned to echo before.

But I can not find the data on the Ajax success function

  success: functions (data, textstats, XMLHTPRAEvieve) {var Comment = data [0] .data; Warning (comment); // shows some undefined   

(as I was getting data like this when I was sending back the data of comments in the PPP function, thus resonating $ JsonData and Comment data in the success function = Data data)

So now I need to get an array $ arr2 by AJAX call so that json_encode will return the data with the array ($ JsonData, $ arr2), not working As is doing $ JsonData is already in JSON format Jason encoding in A server side may cause problems.

But if I juse jquery json parse the following jQuery.parseJSON (data [0]); So I comment in my way = jQuery.parseJSON (data [0]). get data.

If parseJson does not work on all jquery versions, then by other means I can escape from consumer call from json_encode timeline $ JsonData is already in json format and things to work in success function Brings back FII I used "Jason" as a type of data type in AJAX call.

Another method would be to decode json before combining it with your other data:

Echo json_encode (array (json_decode ($ JsonData), $ arr2)); Make your own Jason in this way:

echo '[' $ JsonData ',' Json_encode ($ arr2)

']';

The array resonates with 2 objects in them.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -