phonegap json array

96 views
Skip to first unread message

mu.u...@gmail.com

unread,
May 16, 2013, 10:12:09 AM5/16/13
to phon...@googlegroups.com
Hi

I am using json to fetch the data from the server to the phonegap app . When i send the single array, the data is fetched correctly .This is the output of json.

 [{"id":"3","name":"jhon"}]

Now when i merge the 2 array through php array_merge at server side and than echo the json_encode . The data appears something like this

 [{"id":"3","name":"jhon"},{"id":"5","class":"4"}]

On phonegap when i get the data through ajax i only able to get the data of first array .

 {"id":"3","name":"jhon"}

Where as i tested the code by accessing webpage and it shows all the data but when i putt it on phonegap it only show the first array .


Kerri Shotts

unread,
May 16, 2013, 4:56:38 PM5/16/13
to phon...@googlegroups.com
Not really enough information. Some code would be helpful as to how you are generating the XHR and parsing the results. Also, make sure you aren't caching your responses.


___________________________________
Kerri Shotts
photoKandy Studios, LLC


Social Media:
          Twitter: @photokandy, http://twitter.com/photokandy
          Tumblr: http://photokandy.tumblr.com/
          Github: https://github.com/kerrishotts
                        https://github.com/organizations/photokandyStudios
          CoderWall: https://coderwall.com/kerrishotts

Apps on the Apple Store:

Books:

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

us ahmed

unread,
May 17, 2013, 11:07:53 AM5/17/13
to phon...@googlegroups.com
here is the code
              $.ajax({
                     type: "GET",

                     cache: false,
                     url: "xxxx?id="+id,,
                     success: function(data){
                     var obj = jQuery.parseJSON(data);
                     var json = $.parseJSON(data);
                     /* When i putt the alert here alert(json);
                        It shows me all the values
                     */ 
                     $(json).each(function(i,val){

                                  $.each(val,function(k,v){
                                    /*
                                      But here it only give the first array . This woks ok with the webpage but on phonegap i am getting only first array .
                                    */
                                   });
                              });
                          }
                      });



You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/65-99ZpDYG0/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.

Kerri Shotts

unread,
May 17, 2013, 5:32:37 PM5/17/13
to phon...@googlegroups.com
It's got to be your code. You say in your first comment that an alert there shows everything, so it's clearly not the server's fault.

Don't use alert() for debugging. Use console.log instead: that way you won't be surprised if an alert gets missed.

Second, if that doesn't help, see if you can do the processing in regular JS. If you can, then it's either your jQuery code (which I am not enough an expert in to tell if it is wrong or not) or the jQuery library either being the wrong one (or not behaving properly under PG).

Oh, and is that double comma intentional? I don't think it'll mess anything up, but you never know...

___________________________________
Kerri Shotts
photoKandy Studios, LLC


Social Media:
          Twitter: @photokandy, http://twitter.com/photokandy
          Tumblr: http://photokandy.tumblr.com/
          Github: https://github.com/kerrishotts
                        https://github.com/organizations/photokandyStudios
          CoderWall: https://coderwall.com/kerrishotts

Apps on the Apple Store:

Books:

Reply all
Reply to author
Forward
0 new messages