3
我想通過使用jQuery更新用戶字段。我使用jQuery的setInterval得到「函數未定義」。爲什麼?
我的代碼...
jQuery(document).ready(function(){
setInterval("imStillAlive()", 6000);
function imStillAlive() {
jQuery.post('/users/update_useractive',
function(data){
alert("updated");
});//post
}
});
RAN時顯示錯誤上面的代碼...
「imStillAlive」 沒有定義
如何解決這個問題?
(document).ready inside imStillAlive怎麼回事? – 2010-11-29 05:33:12
Chinmayee,Alex的解決方案不使用(document).ready。 (function($){})(jQuery);是一個自我執行的匿名函數。 – 2010-11-29 05:52:58