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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:05:57+00:00 2026-06-04T05:05:57+00:00

The idea of the code I´m developing right now is extracting data from a

  • 0

The idea of the code I´m developing right now is extracting data from a JSON file (which I get from a server) and then show the results using a beautiful and nice graphic. The problem is I can’t retrieve the object where I save the JSON results in the Jquery code so I can load them in the graphic.
To simplify, my code is like this (Javascript part)

var obj; //I initialize it here in order to make it global though it doesn't work

function handle_json() {
  if (http_request.readyState == 4) {
     if (http_request.status == 200) {
      var json_data = http_request.responseText; 
      obj = eval("(" + json_data + ")");
      //at this point I have the information I want in "obj"
} else {
  alert("A problem ocurred.");
}
http_request = null;

}
}

But now I want to send “obj” to my jQuery code so I can access to the information and show it.
But if try this (jQuery part)

$(function () {
 alert(obj.results.bindings[0].a.value); //<-- this doesn't work, obj isn't initialized
var fert = [];
fert = [[1990, 1.28], [1995, 1.25], [2000, 1], [2005, 1.3], [2010, 1.83]];

var plot = $.plot($("#placeholder"),
       [ { data: fert, label: "Fertility"} ], {
           series: {
               lines: { show: true },
               points: { show: true }
           },
           grid: { hoverable: true, clickable: true },
           yaxis: { min: 0, max: 2}
         });

I see what the problem is, I’ve made an asynchronous Ajax call and I need to execute jQuery right after I evaluate de json info ( obj = eval(“(” + json_data + “)”) ) but I just don’t know how!
If it helps I’ve used a library called “flot” to do the graphics.
Thanks a lot! Any help would be apreciated 🙂

  • 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-04T05:05:58+00:00Added an answer on June 4, 2026 at 5:05 am

    Currently your jQuery code is in a document ready handler, so (obviously) it runs as soon as the document is ready – timing that isn’t related to your Ajax call at all. Instead, put your jQuery code in its own function and call it from right after you set obj. Or just move the jQuery code directly into the function where you set obj:

      var json_data = http_request.responseText; 
      obj = eval("(" + json_data + ")");
      //at this point I have the information I want in "obj"
      // either process obj directly here, or call a function to do it...
      processData(obj);
    
      ...
    
      function processData(obj) {
         // your jQuery code here, using obj
      }
    

    Better though, since you’re using jQuery anyway, would be to do the Ajax with one of jQuery’s Ajax functions. I’d suggest $.getJSON().

    $.getJSON("yourURLhere", function(obj) {
        // your jQuery code using obj here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello im developing a blog right now... but i don't have idea how to
I am currently developing jquery code that sends data to the server via ajax
I am developing a web page code, which fetches dynamically the content from the
In android i am developing a for c2dm push-notification.And get idea about push-notification from
I'm try something from this comment idea Code Igniter Controller/Model name conflicts find class
any idea how i can get the code below to produce this output? 1
I am developing an android application where i have data in Norwegian language. Now
I'm currently developing a couple of modules to reuse code from my controllers on
I am developing application for .Epub extension file reader.I have source code available. But
I am developing an ASP.net Web Application. I have an weird incident right now:

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.