我試圖在live()函數中使用AJAX,但它不起作用。有什麼建議麼? AJAX調用工作(見例1),點擊是registred(見alertbox 1,例2),但調用它時,內部的生活() - 點擊,AJAX調用不返回任何數據沒有AJAX調用live() - 綁定點擊
//Ajax function which gets called
function ajaxFunc(){
$.get("test.php", function(data){
alert(data); //Says "hello nerd!" from PHP script
});
}
//Example 1. Works fine.
$('#button').click(function(){
ajaxFunc(); //Alerts "hello nerd!"
});
//Example 2. Does not work
$('.category_item').live('click', function(){
alert("Testing. Yes, click works)"; //Alertbox 1,
ajaxFunc(); //Alerts a empty alertbox Alertbox 2
});
,您使用的例子是在同一目錄下的頁面? – RageZ 2010-12-16 07:56:15
這個警報是否被觸發警報(「Testing。Yes,click works)」; – kobe 2010-12-16 07:57:49
+1「hello nerd!」。另外,有趣的問題。 – 2010-12-16 08:01:27