After I posted my message, I tried that but I want to capture the current value of 'id' at the time of function definition, not a reference to it since it could change by the time the handler gets called. This seems like it should be easy, but I'm kinda confused. How do I capture the value of 'id' at the time I define that handler function?
Thanks for the reply! On Nov 27, 1:57 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote: > 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