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 に答える