日期:2014-05-16  浏览次数:20585 次

看教程搞了ajax,不知道问什么会出错
Ajax2.js 文件
// JavaScript Document
var xmlhttp
function s_xmlhttprequest() {
if(window.activexobject) {
xmlhttp = new activexobject('microsoft.xmlhttp');
} else if(window.xmlhttprequest) {
xmlhttp = new xmlhttprequest();
}
}

function funphp100(url){
s_xmlhttprequest();
xmlhttp.open("get","for.asp?id="+url,false);
xmlhttp.onreadysatechange=byphp;
xmlhttp.send(null);
}

function byphp(){
var byphp100 = xmlhttp.responseText;
document.getElementById('php100').innerHTML= byphp100;
}

index.asp内容
<script type="text/javascript" src="ajax2.js"></script>
<a href="#" onClick="funphp100(o)">o</a>
<a href="#" onClick="funphp100('t')">t</a>
<a href="#" onClick="funphp100('x')">x</a>
<div id="php100"></div>

for.asp内容

<%
id=request.QueryString("id")
for i=1 to 10
response.Write(id&"<br />")
next
%>
帮我看下,写了

------解决方案--------------------
try:
HTML code
var xmlhttp
function s_xmlhttprequest() {
if(window.activexobject) {
xmlhttp = new activexobject('microsoft.xmlhttp');
} else if(window.xmlhttprequest) {
xmlhttp = new xmlhttprequest();
}
}

function funphp100(url){
s_xmlhttprequest();
xmlhttp.open("get","for.asp?id="+url,false);
//xmlhttp.onreadysatechange=byphp;
xmlhttp.send(null); 
//}

//function byphp(){
var byphp100 = xmlhttp.responseText;
document.getElementById('php100').innerHTML= byphp100; 
}

index.asp内容
<script type="text/javascript" src="ajax2.js"></script>
<a href="#" onClick="funphp100(o)">o</a>
<a href="#" onClick="funphp100('t')">t</a>
<a href="#" onClick="funphp100('x')">x</a>
<div id="php100"></div>

for.asp内容

<%
id=request.QueryString("id")
for i=1 to 10
response.Write(id&"<br />")
next
%>

------解决方案--------------------
什么问题错误啊。返回的类型对吗
function byphp(){
var byphp100 = xmlhttp.responseText;
document.getElementById('php100').innerHTML= byphp100; 
}


 xmlhttp.responseXML的呢?