Jump to content


This topic is now archived and is closed to further replies.


callback function

Recommended Posts

Hi All
Just 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; ?


Share this post

Link to post
Share on other sites
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!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.