Jump to content

callback function


redbullmarky

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; ?

cheers
Mark
Link to comment
https://forums.phpfreaks.com/topic/14162-callback-function/
Share on other sites

Archived

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

×
×
  • Create New...

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.