I’ve been trying to work out how to pass additional parameters to a javascript callback function.
In similar posts users have succeeded using anonymous function (these are new to me so I may have been doing them wrong) but I just can’t get them to fire.
The below is what I have now, I need to be able to pass the itemId to the function “ajaxCheck_Callback” as well as the response.
Hope this makes sense.
Thanks for the help.
function delete(itemId)
{
selectpage.ajaxCheck(itemId, ajaxCheck_Callback);
}
Function ajaxCheck_Callback(response)
{
alert(response);
alert(itemId);
}
Thanks for the help guys. I now get undefined on my alert whereas previously this was alerting correctly.
function delete(itemId)
{
selectpage.ajaxCheck(itemid, function () {ajaxCheck_Callback(itemid); });
}
function ajaxCheck_Callback(response)
{
alert(response);
alert(itemId);
}
The way is usually done is to use an anonymous function.
Careful with your syntax, there are some errors in there. The
functionkeyword has a lower-casefand you can’t have a function nameddelete, that’s a reserved keyword.