Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.