简体   繁体   中英

Pass associative array to Javascript function

How can I pass associative array in the below code. I dont wish to create a variable

uiDialog([MyURL,null,'GET'],false);

Some thing like this

 uiDialog([url:MyURL,data:null,method:'GET'],false);

I know I can do something like

var arr = new Array(5);
  arr["000"]="Rose";
  arr["4"]="Ltd";

And pass this array but I am not interested in that I want a one line code

UPDATE It seams there is no one line solution but if object is not a problem ie u cant use array function or length you can try this answer Pass associative array to Javascript function

 uiDialog({url:MyURL,data:null,method:'GET'},false);
var arr = new Array(3);
arr['url']=MyURL;
arr['data']=null;
arr['method']='GET';

uiDialog(arr,false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM