I'm trying to display a single digit integer (0 and 1) coming as an HTTP response. I'm not sure how to get that integer and store it? What function should I use?
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
// ...what goes here?...
}
setTimeout("loadJSON()", 1000);
}
}
http_request.open("GET", data_file, true);
http_request.send();
}
The response of AJAX calls like that is accessible from the responseText
property:
if (http_request.status == 200) {
doStuffWith(http_request.responseText);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.