在Jquery函数中传递变量时遇到问题

在Jquery函数中传递变量时遇到问题,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, '" + es

我有这个功能

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
。我将修改您的答案以使用匿名函数。
setTimeout(function () {
    finishAjax('talkdesc', a, escape(response));
}, 400);