Jump to content


Photo

callback function


  • Please log in to reply
1 reply to this topic

#1 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 10 July 2006 - 11:16 AM

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
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 10 July 2006 - 11:33 AM

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
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users