我有這樣的jQuery代碼和我jQuery的操縱被傳遞的對象引用
$('.parent').livequery('change', function() {
$(this).parent('.show_sub_categories').append('<img src="nlevel_ajax_dropdown/loader.gif" style="float:left; margin-top:7px;" id="loader" alt="" />');
$.post("nlevel_chid_categories.php", {
parent_id: $(this).val(),
}, function(response){
var ref = $(this).parent('.show_sub_categories');
setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"','"+ref+"')", 400);
});
return false;
});
});
function finishAjax(id, response,ref){
$('#loader').remove();
$(ref).append(unescape(response)); // and this is giving error
}
元素我想提出的是阿賈克斯完成後調用finishAjax功能,並將結果追加到元素的父元素上事件所以我試圖通過var ref = $(this).parent('.show_sub_categories');
獲得其父母的參考,並通過finishAjax
調用setTimeout
函數,但這是拋出jquery錯誤。
下面是實際工作中的錯誤信息: Syntax error, unrecognized expression: [object Object]
(function(e,t){function _(e){var t=M[e...y",[],function(){return v})})(window);
應該添加錯誤。 – MisterJ 2013-05-14 07:30:20
@MisterJ檢查更新後的帖子。 – ravisoni 2013-05-14 07:35:38