jQuery 中的 SimpleModal
我在 jQuery 中使用 SimpleModal,并使用 Ajax 来显示单选按钮。 它应该列出单选按钮和值。 单击单选按钮后, 该页面将被重定向到 page2。
当我在本地主机上测试它时,一切都很好。 但它不会重定向 Web 服务器上的页面。
我应该做出什么改变吗?
我的代码:
..............
$.ajax({
url: 'test.php',
cache: false,
success: function(data) {
$('#resp').modal({
close: false,
position: ["4%",],
overlayId: 'confirmRespOverlay',
containerId: 'confirmRespContainer',
onShow: function (second) {
second.data.find(".buttons .yes").hide();
var resp = $("<div/>").append(data);
var title = resp.find("#title").html(),
message = resp.find("#message").html();
second.data.find(".header span").html(title);
second.data.find('.info').append(message);
second.data.find('.yes').click(function () {
});
}//onShow
}); //Resp
$("input:radio").click(function() {
var url="http://page2"
window.location.replace(url);
}); //input
}//success
}); //ajax
test.php 返回以下
echo "<tr><td><input type=\"radio\" name=\"value_\" onClick=\"showUser(this.value)\" value=".$id1.">".$val1."</td><td>".$name."</td></tr>";
echo "<tr><td><input type=\"radio\" name=\"value_\" onClick=\"showUser(this.value)\" value=".$id2.">".$val2."</td><td>".$name."</td></tr>";
内容 单击单选按钮后页面停止并且不会移至下一页。 我该如何解决这个问题?
I am using SimpleModal in jQuery, and I use Ajax for displaying radio buttons.
It should list the radio button and values. After the radio button click,
the page is to be redirected to page2.
When I tested it on localhost, everything was fine. But it doesn't redirect
the page on the web server.
Any change I should make?
My code:
..............
$.ajax({
url: 'test.php',
cache: false,
success: function(data) {
$('#resp').modal({
close: false,
position: ["4%",],
overlayId: 'confirmRespOverlay',
containerId: 'confirmRespContainer',
onShow: function (second) {
second.data.find(".buttons .yes").hide();
var resp = $("<div/>").append(data);
var title = resp.find("#title").html(),
message = resp.find("#message").html();
second.data.find(".header span").html(title);
second.data.find('.info').append(message);
second.data.find('.yes').click(function () {
});
}//onShow
}); //Resp
$("input:radio").click(function() {
var url="http://page2"
window.location.replace(url);
}); //input
}//success
}); //ajax
test.php returns following
echo "<tr><td><input type=\"radio\" name=\"value_\" onClick=\"showUser(this.value)\" value=".$id1.">".$val1."</td><td>".$name."</td></tr>";
echo "<tr><td><input type=\"radio\" name=\"value_\" onClick=\"showUser(this.value)\" value=".$id2.">".$val2."</td><td>".$name."</td></tr>";
The page stopped after clicking the radio button and doesn't move to next page. How can I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,当您注册事件时,您的输入尚未添加。
有两个选项,一是在显示数据之前将数据加载到模式中(即绕过 onshow 方法),
或者在 onshow 方法内注册事件
It seems to me that your inputs haven't been added when you are registering the events.
There are two options one load your data into the modal before showing it (ie. bypassing your onshow method)
Or register your events inside the onshow method