传递变量在jQuery函数
问题描述:
遇到问题我有这个功能传递变量在jQuery函数
function procData(a) {
$('#loading' + a).show();
$.post("ajax.php?talk=" + a, {
slot: $('#slot' + a).val()
}, function (response) {
$('#talkdesc' + a).fadeOut();
setTimeout("finishAjax('talkdesc', a, '" + escape(response) + "')", 400);
});
}
function finishAjax(id, a, response) {
$('#' + id + a).html(unescape(response));
$('#' + id + a).fadeIn();
}
在procData(),我想传递变量“a”到finishAjax,但似乎没有任何工作。它在除了这个之外的所有被调用的区域都可以工作。有任何想法吗?
答
setTimeout(function() {
finishAjax('talkdesc', a, escape(response));
}, 400);
恐怖!不要将字符串传递给'setTimeout'。我将修改您的答案以使用匿名功能。 – 2010-08-03 05:06:44
@熊感谢! – Amarghosh 2010-08-03 09:58:37