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

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.

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]);

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.