Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:08:21+00:00 2026-06-04T14:08:21+00:00

In a function I make an ajax call, the call back has the response_text

  • 0

In a function I make an ajax call, the call back has the response_text I need in that function. I tried the obvious of putting a var here in the calling function and using it in the callback function. This does not work. Next I tried using a function out() which is how I’ve done this before. This works as I can now access response_text from out(). However, is there a way to access from vOrb() directly, that is, the original calling function?

I don’t want to place all the code in the call back as in this SO Question

Would the module pattern work as a way to keep var here in scope when the callback function make its asynchronous return? Or would simply writing var vOrb = function(){} as a wrap and call using new, do the trick?

function vOrb( icon_array )
{
    var here; // does not work
    function out( here ){} // does work
    new AjaxRequest().invoke( 'ajax_type=fav_dir', function( response_text )
    {
        out( response_text );
    } ); 

// want response_text here
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:08:23+00:00Added an answer on June 4, 2026 at 2:08 pm

    I’m not sure if I understood everything right but I’ll try to answer anyway.
    If this is what you want, you can’t use response_text outside your callback – it would be undefined.

    It’d be better to proceed like so :

    function vOrb( icon_array )
    {
        new AjaxRequest().invoke( 'ajax_type=fav_dir', myCallback ); 
        var myCallback = function ( response_text ) {
            // blah…
        };
    }
    

    If you absolutely want to use response_text outside your callback, then you’ll have to check if it is set first.

    var my_response;
    function vOrb( icon_array )
    {
        new AjaxRequest().invoke( 'ajax_type=fav_dir', myCallback ); 
        var myCallback = function ( response_text ) {
            my_response = response_text;
        };
    }
    
    // ...
    
    if ( typeof my_response !== 'undefined' ) { // will only work after the callback is triggered
        // use "my_response" here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Ajax calls. I need to make sure that a JS function
I make a call to a php file using jquery's ajax function. It goes
I have a javascript function that calls a generic function to make an ajax
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I have a JavaScript class that has a method: function someClass() { this.someMethod =
I have a javascript function which asks for some ajax data and gets back
I have an MVC 3 web app that has an Action which I need
If I make a jquery AJAX request which is succesful I get back my
I make a jquery plugin look like: (function($){ $.fn.plugin_name = function(){ var methods =
i have the following code and the call back function is not being called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.