ajax基础运行不出来? - Web 开发 / Ajax
index.html:
HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Using</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest() {
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("post", "in.html", true);
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.getElementById("results").innerHTML = xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<input type="button" value="Search" onclick="startRequest();"/>
<div id="results"></div>
</body>
</html>
in.html:
HTML code
Cod
相关问答:
RT!
xmlHttpRequest.send("提交参数名=值&提交参数名1=值");
var date={"数据1":"数据1值","数据2":"数据2值","数据3":"数据3值" ......
代码中,如果将//alert(1) 注释打开,那么就可以调用,如果注释掉就无法调用
怀疑是导JS文件出问题了,因为写过jsp引两个JS文件没问题,
而JSP引一个JS文件,这个JS引别外的JS文件出现下面问题,上网找了半天没结 ......
在本地测试时可以的。
上传到服务器就出现没有权限问题。
网上搜索说不能够跨域,但是我没有跨域啊!
都是在服务器上面怎么会有跨域呢?
该怎么解决??????
代码贴出来。。
function Ajax(url,parm,fu ......
代码如下 请高手 指点下 谢谢
ajax_http.js
-------------
function getXMLHTTP() {
var xmlhttp;
if (window.ActiveXObject) {
//IE
try {
......