我想知道是否可以将AJAX函数中的xmlhttp.responseText值返回到最初调用AJAX函数的函数
function ajaxfunc(adiv,url,parameter){
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
responseText_data = xmlhttp.responseText;
//how to return responseText_data to myfunc();
}
}
parameters = parameter;
xmlhttp.open('POST',url,true );
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send(parameters);
}
function myfunc(){
url = 'insidefunc.php';
adiv = "";
parameter = 'selected='+'selected';
ajaxfunc(adiv,url,parameter);
//alert(responseText_data);
}