2009-02-09 36 views
0

我在jQuery中使用SimpleModal,并使用Ajax显示单选按钮。 它应该列出单选按钮和值。点击单选按钮后, 页面将被重定向到page2。jQuery中的SimpleModal

当我在本地主机上测试它时,一切都很好。但它不会在网页服务器上重定向 页面。

我应该做什么改变?

我的代码:以下

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>"; 

.............. 
$.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的回报点击单选按钮后停止,不会移动到下一个页面。我该如何解决这个问题?

+0

内您的活动在什么地方showUser函数进入它吗? – roborourke 2009-02-09 09:55:47

回答

1

在我看来,您注册事件时尚未添加您的输入。

有两种选择一个显示它(即绕过你的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 

}); //ajax