tags:

views:

27

answers:

1

Hi, I have this function

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();
}

In procData(), I'm trying to pass the variable 'a' to finishAjax, but nothing seems to work. It works in all the areas where it is called except this one. Any ideas?

+1  A: 
setTimeout(function () {
    finishAjax('talkdesc', a, escape(response));
}, 400);
Amarghosh
The horror! Don't pass strings to `setTimeout`. I'm going to modify your answer to use an anonymous function.
Matt Ball
@Bears thanks !
Amarghosh