0

我可以用 jquery ui 对话框打开一个 html 页面。

这是我的代码

var openDialog = $( "#dialog" ).dialog({
  height:500,
  width:500,
  modal: true,
  buttons: {
    Cancel: function() {
      $( this ).dialog( "close" );
    }
  }
});

openDialog.load("testPage.html").data("userID",this.model.userID).dialog('open');

我需要将数据 [几个值] 发送到 testPage.html 并尝试使用如上所示的数据并尝试在我的 testPage.html 中使用

var test =  $("#dialog").data("userID");
alert(test);

这显然是错误的做法。有没有办法做到这一点?

4

1 回答 1

0

我将使用您要发送 testPage.html 的数据构造一个查询字符串,然后在 testPage.html 上有一些代码来读取查询字符串并对这些值执行任何操作。

这应该会有所帮助,它只是一个从查询字符串中获取值的函数。

function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

希望这可以帮助。

于 2013-05-16T17:43:50.660 回答