我在jQuery中使用SimpleModal,并使用Ajax显示单选按钮。它应该列出单选按钮和值。单击单选按钮后,页面将重定向到page2。
当我在localhost上测试它时,一切都很好。但它不会重定向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
}); //ajaxtest.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>";页面在单击单选按钮后停止,并且不会移动到下一页。我如何解决这个问题?
发布于 2009-02-09 20:27:38
在我看来,当你注册事件时,你的输入没有被添加。
有两种选择,一种是在显示数据之前将数据加载到模式中(即。绕过你的onshow方法)
$.ajax({
url: 'test.php',
cache: false,
success: function(data) {
var second = $('#resp');
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 () {
}); // click
$('#resp').modal({
close:false,
position: ["4%",],
overlayId:'confirmRespOverlay',
containerId:'confirmRespContainer'
}); //Resp
$("input:radio").click(function() {
var url="http://page2"
window.location.replace(url);
}); //input
}//success
}); //ajax或者在onshow方法中注册事件
$.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 () {
});
$("input:radio").click(function() {
var url="http://page2"
window.location.replace(url);
}); //input
}//onShow
}); //Resp
}//success
}); //ajaxhttps://stackoverflow.com/questions/527457
复制相似问题