gpt4 book ai didi

javascript - jQuery 用户界面 : How to pass values to dialog

转载 作者:行者123 更新时间:2023-12-02 20:14:10 26 4
gpt4 key购买 nike

我对 JQuery UI 非常陌生。我在使用 JQuery 加载模式对话框窗口时遇到问题。在这里,我尝试简单的示例,它将打开对话框并在单选按钮的 onClick 事件上加载新页面。加载到对话框中的新页面是动态页面,它根据通过主页文本框提供的用户输入从数据库中获取一些值。

我不知道如何传递该值 主页上的文本框?也索德 我试图传递文本的值 通过将 url 属性附加到框 网址..但没有运气:(。即我的网址是 回归测试自定义元数据选择.action 我试图将其传递为 回归测试自定义元数据选择.action*?消费者* 消费者从文本中获取值(value) 盒子。这是正确的方法吗?提供下面的代码

<!DOCTYPE html>

<html>
<head>
<script type="text/javascript" language="javascript" src="JS/jquery-1.6.1.js"></script>
<script type="text/javascript" language="javascript" src="JS/jquery-ui-1.8.14.custom.min.js"></script>



<style type="text/css" title="currentStyle">
@import "css/jquery-ui-1.8.4.custom.css";
</style>

<script type="text/javascript">
$(document).ready( function(){
$("#CUSTOM").click( showDialog );
//variable to reference window
myWindow = $('#dialog');

}
);
//function to show dialog
var showDialog = function() {
//instantiate the dialog

myWindow.load("regressionTestCustomMetadataSelection.action?consumer").dialog({ height: 350,
width: 400,
modal: true,
position: 'center',
autoOpen:false,
title:'Hello World',
overlay: { opacity: 0.5, background: 'black'}
});

//if the contents have been hidden with css, you need this
myWindow.show();
//open the dialog
myWindow.dialog("open");
}
//function to close dialog, probably called by a button in the dialog
var closeDialog = function() {
myWindow.dialog("close");
}
</script>

<script>




function setSession()
{
$(document).ready(function() {
$("#dialog").load("regressionTestCustomMetadataSelection.action?as").dialog({ modal: true, resizable: false, draggable: false, width: 515, height: 245 });
});

$("#dialog").dialog('open');
}
</script>
</head>
<body style="font-size:62.5%;">
<div>
<input type="radio" name="submittedMetadataSelection" id="DEFAULT" value="DEFAULT" checked/>
<label for="DEFAULT">DEFAULT</label>

<input type="radio" name="submittedMetadataSelection" id="CUSTOM" value="CUSTOM" "/>
<label for="CUSTOM">CUSTOM</label>

</div>
<div id="dialog" title="Dialog Title"></div>

</body>
</html>

最佳答案

尝试使用 $.ajax 方法而不是“load”,并使用“data”对象发送参数:

$.ajax({
url: "regressionTestCustomMetadataSelection.action",
data: ({customer: "John"}),
traditional: true,
success: function(loadedData) {
// assuming that the contents of loadedData is html
myWindow.html(loadedData);
myWindow.dialog();
}
});

关于javascript - jQuery 用户界面 : How to pass values to dialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6550634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com