I’m new to JS, and am sure this must be pretty basic, but I can’t seem to get it to work.
I am using a little bit of JS to retrieve a value from a web server into an app.
The JS looks like:
function done(response) {
console.log(response);
var json = JSON.parse(response);
console.log(json);
console.log(json.quote);
}
Request.get("http://www.mysite.com/mypage.php")
.then(done)
.catch(function(error) {
Quote.string = "hello world";
});
I have a text box on that screen that I want to display the retrieved string when a button is tapped.
With the code above using “hello world” it correctly displays “hello world”, so the button tap is working.
And I can see in the console log the correct retrieved value.
But I can’t get the retrieved value to appear in my Quote.string test box.
I have tried using:
var json
json
json.quote
response
(response)
Presumably if the value is getting retrieved it must be possible to call it to appear in the Quote.string?
Thanks.