javascript - viewer.loadImageFromJSON with variable not working -


i have following javascript works (with jquery):

function(test) {                     var neuroimages = viewer.loadimagefromjson('../data/new/res_neg_subj_val_5.nii.json', 'neg_subj_val_5', 'hot , cold');         return neuroimages;     }; 

now want use variable (lets picture) instead of '../data/new/res_neg_subj_val_5.nii.json', 'neg_subj_val_5', 'hot , cold' , format code accordingly:

function(test) {                  picture = "'../data/new/res_neg_subj_val_5.nii.json', 'neg_subj_val_5', 'hot , cold'";                     neuroimages = viewer.loadimagefromjson(picture);                  return neuroimages;                 }; 

this not work.

neither this:

function(test) {                  pic1 = "'../data/new/res_neg_subj_val_5.nii.json', 'neg_subj_val_5', 'hot , cold'";                    pic2 = "'neg_subj_val_5'";                  pic3 = "'hot , cold'";                  neuroimages = viewer.loadimagefromjson(pic1, pic2, pic3);                  return neuroimages;                 }; 

what doing wrong there? tried google , several sites no success. not mention i'm quiet beginner java , near insanity.

you right second example. here should specify 1 piece of data each variable (at least in case, there ways specify many pieces of data in single variable such arrays , objects). need have 1 set of quotes surrounding each string (doesn't matter whether single or double quotes long match). also, precede variables 'var' keyword unless want them global.

function(test) {   var pic1 = "../data/new/res_neg_subj_val_5.nii.json";     var pic2 = "neg_subj_val_5";   var pic3 = "hot , cold";   neuroimages = viewer.loadimagefromjson(pic1, pic2, pic3);   return neuroimages; }; 

making first attempt work little more tricky passing array function expects 3 distinct variables. this:

function(test) {   var picture = ['../data/new/res_neg_subj_val_5.nii.json', 'neg_subj_val_5', 'hot , cold'];      neuroimages = viewer.loadimagefromjson.apply(viewer, picture);   return neuroimages; }; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -