Jump to content

array as function paramater


mrdhood

Recommended Posts

I have a function that I need accessed two ways. The first way works which is with an ajax json request.

it loads name(data) which then does alert(data['user_info']['username']);

This works perfect.

However I can't figure out how to set it up when a user clicks a span element it alerts their username. An exmaple code that I'm trying to use would be something like this:

 

<span onclick="name('[\'user_info\':[\'username\':\'test\']]');">click</span>

 

This will not work.

 

alert(data); results in "['user_info':['username':'test']]"

 

It won't convert it to an array.

using new Array() did not help. (at least the way I tried).

 

Thanks for any help. I did try to search, I'm probably doing some dumb mistake that I'm just overlooking.

Link to comment
https://forums.phpfreaks.com/topic/238291-array-as-function-paramater/
Share on other sites

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.