Jump to content

Troubles getting at data after splitting out the array


phpjayx

Recommended Posts

I'm very new to Java, and a lot of coding in general...

 

I found some code to get browser information of the user and have successfully transfered from my PHP controller file to my .JS file and come to this string (returnString2)

 

{"0":"mozilla","1":"5","name":"mozilla","version":"5"}

 

I know that the returnString2[x] gives me the a piece of the array, but extracting it from there is my problem

 

I want to get at the variable "name", but I'm having trouble getting it.

I'm sure its very simple, but if someone could explain I would be greatful!!!! :)

 

 

Thanks in advance

Link to comment
Share on other sites

I have now attempted to use .toString() and I run across teh same problem.

 

The furthest I get down to is if I do a SPLIT again on

sp2=sp1[2].split(":");

 

and then I can grab sp2[2], but the string it writes over to my innerHTML variable includes the quotes, which becomes problematic further down the line.... So I get literally with the quotes "mozilla"

Still no luck. Help would be greatly appreciated.

Edited by phpjayx
Link to comment
Share on other sites

That wasn't quite it, I was attempting to do it in my .JS....

But thank you, you lead me down a different path of thinking and I finally got it.. Below is what I came up with in my JS and it works.

 

function parseDataJson(returnValue)

{

var Datax = $.parseJSON(returnValue);

 

alert(Datax[0]);

 

}

Edited by phpjayx
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.