试图干掉我写的一些旧的javascript.
测试()
function test() {
var output = function() {
return ajaxPost("test.php", "testvar=bananas");
}
document.getElementById("main").innerHTML = output;
}
Run Code Online (Sandbox Code Playgroud)
ajaxPost()
function ajaxPost(file,stuff) {
var xmlhttp;
var actionFile = file;
var ajaxVars = stuff;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
return xmlhttp.responseText;
} else {
// Waiting...
}
}
xmlhttp.open("POST", actionFile, true);
//Send the proper …Run Code Online (Sandbox Code Playgroud)