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 830753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:05:48+00:00 2026-05-15T04:05:48+00:00

Got some basic problem again. I need to modify a function that previously returned

  • 0

Got some basic problem again.

I need to modify a function that previously returned a in code written object.
Im now trying to get the object from json through $.getJSON

function getEventData() {
  var result = '';

  $.getJSON("ajax.php?cmd=getbydate&fromdate=&todate=", function(data) {
    result = data;
  });
  return result;
}

Problem is that result isn’t set in the callback function for obvious reasons.

Do you guys have a solution for this?

Edit:
Ok i got an answer that was removed.
I just had to change it abit..

This is the answer that works:

function getEventData() {
  var result = '';
  url = "ajax.php?cmd=getbydate&fromdate=&todate=";
  $.ajax({
    url: url,
    async: false,
    dataType: 'json',
    success: function(data) {
      result = data;
    }
  });
  return result;
}
  • 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-05-15T04:05:49+00:00Added an answer on May 15, 2026 at 4:05 am

    You should program your application in an asynchronous way, which means, that you should use callback functions for you application flow, too, or continue in the getJson callback function. You can also make the request synchronously which should then be able to return the value (or at least assign it and block the function till the callback is completed), but this is not recommended at all:

    function getEventData() {
      var result = '';
    
      result = $.ajax({
        url: "ajax.php?cmd=getbydate&fromdate=&todate=",
        async: false,
        dataType: "json",
        data: data,
        success: function(data) {
          return data;
        }
      });
      return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some example Python code that I need to mimic in C++. I
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I got some quite strange errors compiling code under gcc. It tells me that
I got some pretty messy urls that i got via scraping here, problem is
Got a small problem with some very basic jQuery, I'd like to be able
I've got some code that needs to run every 2 minutes which seems simple
I've got some basic Java experience and very basic Android app development experience (currently
I'm planning on coding a little basic cms and got some questions. Imagen you
got some problems. Built an applet that has to be used step-by-step. After each
i got some legacy code using: nonblocking socket, select for timeout, read (2) and

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.