Javascript 将变量传递到jQuery ui对话框
我需要将一个名为“test\u var”的变量传递到我的对话框 但我不知道怎么做 如何将调用对话框的函数中的变量传递给对话框Javascript 将变量传递到jQuery ui对话框,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我需要将一个名为“test\u var”的变量传递到我的对话框 但我不知道怎么做 如何将调用对话框的函数中的变量传递给对话框 //a tag calls to starter function and sends variable as parameter <a href="#" onclick="starter(test_var)"> go </a> //starter func recives the test_var and cal
//a tag calls to starter function and sends variable as parameter
<a href="#" onclick="starter(test_var)"> go </a>
//starter func recives the test_var and calls the dialog box
//what i want is to somehow send test_var to dialogbox in here
function starter(test_var){
//some stuff
$('#dialog_div').dialog('open');
return false;
}
}
$('#dialog_div').dialog({
aoutoOpen:false,
with:600,
buttons:{
"ok":function(){
// i want to be able to alert test_var in here
alert(test_var)
}
}
})
}
但它不起作用只需将其设置为顶级变量,然后对话框就可以直接访问它。您想如何处理该变量?我想通过ajax将其发送到另一个页面,但首先我需要用户注释和确认,这就是为什么我需要一个对话框。您需要将该变量用作对话框中显示的一部分吗盒子?变量来自哪里?不,我只想将它发送到另一个页面,它是我的第一个函数(starter())中的一个参数,然后您不需要将它传递到对话框,只需在ajax调用中使用它。
function starter(test_var){
//some stuff
$('#dialog_div').dialog('open' , test_Val);
return false;
}
and
$('#dialog_div').dialog(test_val , {//coode
})