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

  • SEARCH
  • Home
  • 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 8740693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:10:31+00:00 2026-06-13T11:10:31+00:00

That title was a mouthful. Here’s what I’m trying to do in code below.

  • 0

That title was a mouthful. Here’s what I’m trying to do in code below. The callback in this case is in the jQuery $.get function.

      function getMapMarkup(loadUrl, myVar) {
        me = myVar;
        $.get(
            loadUrl,
            { var1: "hello", var2: "world" },
            function(responseText) {
              me = responseText;
              myVar = me; //doesn't work.  
            },
            "html"
         );     
        }

Is there a way to change the value of myVar in the function(responseText) callback, so I can use it in my program later on? Or is there another (better) way to go about what I’m trying to do?

  • 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-13T11:10:32+00:00Added an answer on June 13, 2026 at 11:10 am

    If by later on you mean immediately after the $.get call then no, there is no way because AJAX is asynchronous and the $.get returns immediately and the success callback can be executed much later. The only reliable way to know when this happens is to put the code that depends on its result inside the success callback. You could also call some other function inside the success callback passing it the result of the AJAX call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That title may need some work. Perhaps after reading this, you may be able
eeesh that title isn't very good. Here is the situation. I have a simulation
I know that title sounds crazy but here is my situation. After a certain
If that title did not make sense (which I'm expecting =)) here is what
Folks, I know I didn't phrase that title very well, but here's the scenario.
That title is a mouthful and a bit confusing, but you are still reading
Okay, the title is a mouthful and I think that's probably why it has
Hopefully that title isn't too cryptic. What's happening is I have a jQuery AJAX
Wow, that title was a mouthful... I'm sure that sounds very confusing at first
Title is a bit of a mouthful, but I'm a bit stuck on this

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.