I have read bunch of posts on call backs and asynchronous Ajax nature, however most of them use jQuery and its kind of confusing.
function nextMonth(){
for(var i loop){
for(var p loop){
//once proper i and p found
var output = getData(date);
var result = JSON.parse(output);
//do something with that data
}
}
}
function getData(date){
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var str = xmlhttp.responseText;
return str;
}
}
xmlhttp.open("POST","url",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(encodeURI("date"+date));
}
Loops make it difficult for me to see it, any way with the suggestions on the call back to still keep it functional?
"Ry" marked it a duplicate and linked to the jQuery post, i clearly stated the difference of two questions.