211

RATE

How do you get information / variables out of a JSON return text AJAX statement (done in jQuery) with Javascript?

bobbonew

bobbonew's Avatar

2 years ago

Answers

  • Guest
  • -  0 pts
  • -  (2 years ago)

If your return JSON statement is something like this:

    {"body":"Your message","guestName":"somebody"}


Then in your jQuery success function do something like this:

    success: function(data){
    var myObject = eval('(' + data + ')');
    var body= myObject.body;
    var guestName = myObject.guestName;
    }


Then your free to do anything like this for example (more complex applications at your leisure):

    alert(body);


(That would alert Your message to the browser ;) )

Parasyte's Avatar
  • Parasyte
  • -  6040 pts
  • -  (2 years ago)

Eaahh! My head's gonna explode!

bobbonew's Avatar
  • bobbonew
  • -  2656 pts
  • -  (2 years ago)

Lol Parasyte, I was researching this problem for literally 20+ hours. But rest assured, even though its use is extremely complex, expect incredibly cool features to result from it in the quite near future :D

 

What is Questional?

We interview experts, scientists, and public figures in tech & science as well as community Q & A!

Asking questions and getting answers is what we do.

Subscribe via RSS Subscribe via Email

Recent Literature

Smartphones for the 2011 Holiday Season

With Christmas coming up, Questional.com compares a few of the newest smartphones - the Samsung Galaxy Nexus, the iPhone 4S, and Motorola Droid 4. Which one do you want to...

Jean-Michel Claverie

Jean-Michel Claverie, French scientist extraordinaire, was kind enough to give Questional this interview. Claverie, one of the discoverers of megavirus chilensis, is a pio...

More Tech Toys for the 2011 Holiday Season

Still looking for that unique gift? Questional covers more tech toys for the holiday season. Everything from cuddly pathogens to flying machines, electronic bugs and mind gam...

Tech Toys for the 2011 Holiday Season

Don't buy another iTunes gift card for that office buddy - get a little creative this year. There are some very cool albeit a little quirky tech toys for that hard...

Dear Santa - A Few Holiday 2011 Gadgets I'd Enjoy

Dear Santa,
This year's holiday season is sure to be full of fun gadgets and toys for the tech-savvy, so I thought I'd review a few of my personal favorites...

Request For Interview

Questional is always on the lookout for great interviewees.

If you're a professional, an expert, or feel like your interview would be a great read to our guests + members we want to hear from you! - Contact Us