tags:

views:

21

answers:

2

Hello all
I want to pass a javascript object (JSON) as an argument to another function. But i am getting following error:

missing ] after element list

the function is called on onclick event of href like

"<a href='javascript:void(0);' onclick='javascript:openTab("+ sTab +");'>"+ sTab['SavedTab']['title'] +"</a><br/>";

When i pass whole value : sTab['SavedTab']['title'] , it works fine but i want to pass whole object, not just single value out of it.

Please help me out. Thanks.

A: 

This is because 'javascript:openTab("+ sTab +");', here sTab is a collection and the script cannot do anything for this collection. You would probably have to pass an index as "sTab['SavedTab']['title']"

Ravia
A: 

I believe if your get sTab not as parameter but as variable inside your js function it will work. 'javascript:openTab();'

javascript:openTab(){
   //sTab as global variable will be accessible here
}
Artic