asynchronous function to get data from server

0 Marin Bešlo · September 25, 2015

I have to solve a problem. I hope someone can help me....

"Write a function to async get data from server.
Get JSON data from and with callback call the data"

Hope you understood what my problem is :D

Post a Reply


Oldest  Newest  Rating
+1 Bram Dekker · October 3, 2015
I see that you are using the XMLHttpRequest. Take a look here: :)
0 Marin Bešlo · October 2, 2015
Yea, I did it, but it's not an async function, how could I write it?

var xmlhttp = new XMLHttpRequest();
var url = "";

xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var arr = JSON.parse(xmlhttp.responseText);
}"GET", url, true);

function myFunction(myArr){
for(var i in myArr.movies)
document.write(myArr.movies[i].Title + "");
0 Bram Dekker · September 25, 2015
What did you do to solve the problem yourself? Do you have example code that you wrote? Did you look at references? Perhaps promises might be an idea? We are not here to solve problems but to help you solve the problem :)
0 Brotsky Tv · September 26, 2015
Read this articles might that help you !!

1) Write a function to async get data from server.

For more Javascript tutorials :
  • 1



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.