이 파일을 실행할 때마다 코드가 전송 기능이 실행되는 지점까지 실행 된 다음 경고 ("보낸")를 꺼내면 바로 뒤에 경고 기능이있는 경우에만 코드가 실행됩니다. 그 다음에 ServerReadyyState
은 1로 응답합니다.Ajax send 함수가 실행되지 않습니까?
무엇이 문제 일 수 있습니까? 누군가 제발 도와주세요, 내 로컬 컴퓨터에서 내 개인 서버에 시도하고 동일한 결과를 얻었다. 어떤 도움이라도 대단히 감사합니다.
강령 : asynchronus이
/**
* @author d
*/
var xhr;
function getPlants(xhr) {
try {
xhr = new XMLHttpRequest();
} catch (microsoft) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
xhr = false;
alert("ajax not supported");
}
}
}
xhr.open("GET", "db_interactions.php", true);
xhr.send(null);
alert("sent"); //the send function only works if this alert functions is here
if (xhr.readyState == 4) {
return xhr.responseText;
} else {
alert("Server ReadyState is:" + xhr.readyState);
xhr.abort();
//getPlants(xhr);
}
}
덕분에 많이 도움이되었습니다. –