我正在使用PHP删除记录.我想使用JQuery UI对话框来确认操作,但我不知道如何将变量(我的RecordID)传递给重定向URL函数,或者允许URL访问window.location.href.
$("#confirm" ).dialog({
resizable: false,autoOpen: false,modal: true,buttons: {
'OK': function() {
window.location.href = 'url and myvar??';
$( this ).dialog( "close" );
},'Cancel': function() {
$( this ).dialog( "close" );
}
}
});
$("#delete").click(function() {
$("#confirm").dialog( "open" ).html ( "Are U Sure?" );
return false;
});
HTML
<a href='index.PHP?recordid=$row[recordid]' id='delete'>DELETE</a>
有没有一个很好的方法来做到这一点?
解决方法
您可以尝试使用.data()方法为您存储数据.看看这个答案
Passing data to a jQuery UI Dialog
Passing data to a jQuery UI Dialog
例如,要传递变量,可以在打开对话框之前使用数据函数存储它
$("#dialog_div")
.data('param_1','whateverdata')
.dialog("open");
然后你可以通过以下方式得到这个:
var my_data = $("#dialog_div").data('param_1')