我试图在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