Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  152] [ 4]  / answers: 1 / hits: 159186  / 11 Years ago, tue, april 2, 2013, 12:00:00

I use getJSON to request a JSON from my website. It works great, but I need to save the output into another variable, like this:



var myjson= $.getJSON(http://127.0.0.1:8080/horizon-update, function(json) {

});


I need to save the result into myjson but it seems this syntax is not correct. Any ideas?


More From » jquery

 Answers
11

You can't get value when calling getJSON, only after response.



var myjson;
$.getJSON(http://127.0.0.1:8080/horizon-update, function(json){
myjson = json;
});

[#79162] Monday, April 1, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blaynetheoi

Total Points: 146
Total Questions: 116
Total Answers: 103

Location: India
Member since Thu, Apr 8, 2021
3 Years ago
;