You could wrap your real callback in an anonymous function that adds the
parameters that you want. Maybe something like (untested):

      $.post('/ajax/asset/insert', {
        folder_tid : lastUploadedFolderTID,
        link       : linkQueue[id]
      }, function(data, status) { handleAddLinkComplete.call(this, data,
status, 123); }, 'json');

Good luck with it.

--Erik


On 11/27/07, Rob Barreca <[EMAIL PROTECTED]> wrote:
>
>  I commonly want to pass an ID or some other information I know to an AJAX
> success handler.
>
>       $.post('/ajax/asset/insert', {
>         folder_tid : lastUploadedFolderTID,
>         link       : linkQueue[id]
>       }, handleAddLinkComplete, 'json');
>
>
> In this example, I want to pass an ID to handleAddLinkComplete function. I
> know I can do the following, but they seem crufty to me.
>
>
>    1. I can set a global variable with the link ID, but what if I have
>    a bunch of post calls, there are synchronous issues (I know I can do async 
> :
>    false too)
>    2. I could have my /ajax/asset/insert callback return the link ID
>    back to me in the response, but it seems silly if I already know it.
>
> I would love to do something like...
>
>       $.post('/ajax/asset/insert', {
>         folder_tid : lastUploadedFolderTID,
>         link       : linkQueue[id]
>       }, { callback : handleAddLinkComplete, arguments : [123] }, 'json');
>
> or something.
>
> What is the best way here or is my dream a reality?
>
> Cheers,
>
> -Rob
>

Reply via email to