如何在程序中申明AJAX
程序员文章站
2022-07-06 16:26:08
...
<script type="text/javascript">
var ss="";
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function go() {
createXMLHttpRequest();
var url = "../ReturnXY";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = goCallback;
xmlHttp.send(null);
}
function goCallback() {
if (xmlHttp.readyState == 4) {
alert(xmlHttp.status);
if (xmlHttp.status == 200) {
ss=xmlHttp.responseText;
}
}
}
function dd()
{
alert(ss);
}
</script>
var ss="";
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function go() {
createXMLHttpRequest();
var url = "../ReturnXY";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = goCallback;
xmlHttp.send(null);
}
function goCallback() {
if (xmlHttp.readyState == 4) {
alert(xmlHttp.status);
if (xmlHttp.status == 200) {
ss=xmlHttp.responseText;
}
}
}
function dd()
{
alert(ss);
}
</script>