redbullmarky Posted July 10, 2006 Share Posted July 10, 2006 Hi AllJust wondering if anyone has a different take on this.I'm trying to expand a simple AJAX library that I wrote by allowing a custom callback function on success. The options that can be passed to the first AJAX request is the URL and parameters (mandatory) and also the return DIV/element for the result. Now I want to ALSO be able to pass in a function name, so that as well as putting the data into the DIV/element, it also calls a return function.I can pass the function name into the AJAX library, and it recognises it as a function - the only thing I'm struggling on is how do I actually call this function?I have the line: xmlhttp.onreadystatechange=xmlhttpChange in my code which does the checking of the result/response, etc. How can I get the function xmlhttpChange() to also call my callback function that was passed as a function parameter? ie, without changing the above line to xmlhttp.onreadystatechange=callbackfunc; ?cheersMark Link to comment https://forums.phpfreaks.com/topic/14162-callback-function/ Share on other sites More sharing options...
redbullmarky Posted July 10, 2006 Author Share Posted July 10, 2006 sorry dont worry - figured it out not long after i first posted.i had a few errors, so i didnt realise you could just call a function by the actual parameter name in the function you passed it to...all works now!Cheers Link to comment https://forums.phpfreaks.com/topic/14162-callback-function/#findComment-55474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.