aspx代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using AlbumManagement;public partial class PersonalPicture : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/xml"; string UserID = Request["UserID"].ToString(); AlbumManagement.AlbumClass AlbumInfo = new AlbumManagement.AlbumClass(); //Response.Write(AlbumInfo.AlbumList(Request["UserID"].ToString().Trim())); HttpContext.Current.Response.Write(AlbumInfo.AlbumList(Request["UserID"].ToString().Trim())); //HttpContext.Current.Response.Write(AlbumInfo.AlbumList("52")); Response.Flush(); Response.End(); } }
问题在这里: if(xmlHttp.readyState==4) { alert(xmlHttp.statusText); var xmlobj=xmlHttp.responseXML; alert(xmlHttp.responseXML.xml);是statusText引发了"Object Not Found", 在第一次看帖子时还以为是page not found, LZ换成xmlHttp.status试试就应该好了, 而且,不能光检测 readyState,应当还要检测status,即: if(xmlHttp.readyState==4 && xmlHttp.status == 200) { // your code here ... } status为200才能说明服务器正确返回了
你的"not found"是"object not found"不? 如果是,把 if(xmlHttp.readyState==4) { alert(xmlHttp.statusText); var xmlobj=xmlHttp.responseXML; alert(xmlHttp.responseXML.xml); //.... } 改成 if(xmlHttp.readyState==4) { alert("status:" + xmlHttp.status); var xmlobj=xmlHttp.responseXML; alert("xml: " + xmlHttp.responseXML.xml); //......... }这样就能看出是哪一步出的问题了,如果这样改了有错,可能是第二步出错,不应当是第一步的
<head>
<title></title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpResponse()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function formsubmit(param)
{
createXMLHttpResponse();
if(param=="1")
{
url="PersonalPicture.aspx?UserID=52&flage=&IDLIST=";
}
else if(param=="2")
{
url="PersonalPicture.aspx?UserID=52&flage=Del&IDLIST="+b();
}
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open('get','url',true);
//xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
alert(xmlHttp.statusText);
var xmlobj=xmlHttp.responseXML;
alert(xmlHttp.responseXML.xml);
var elemDoc=xmlobj.getElementsByTagName("Album_Table");
if(document.body.firstChild!=null)
{
document.body.removeChild(document.body.firstChild);
}
document.write('<form id="form" name="form" method="post" action="">');
document.write('<table border="1">');
document.write('<tr>');
document.write('<td>ID</td>');
document.write('<td>文件名</td>');
document.write('<td>图片名</td>');
document.write('</tr>');
for(var i=0;i<elemDoc.length;i++)
{
var Album_Table=elemDoc[i];
document.write('<tr><input type="hidden" name="hiddenAlbum" value='+Album_Table.getElementsByTagName("ALBUM_ID")[0].firstChild.data+'>');
document.write('<td><input type="checkbox" name="checkbox" id="ID_List" onclick="javascript:b()"></td>');
document.write('<td>'+Album_Table.getElementsByTagName("ALBUM_NAME")[0].firstChild.data+'</td>');
document.write('<td>'+Album_Table.getElementsByTagName("FILE_NAME")[0].firstChild.data+'</td>');
document.write('</tr>');
}
document.write('</table>');
document.write('<input type="button" onclick="formsubmit(2)">');
document.write('</form>');
document.close();
}
}
</script>
<script type="text/javascript">
function a()
{
var obj=document.getElementsByTagName("input");
var c=new Array();
for(var i=0;i<obj.length;i++)
{
if(obj[i].checked==true)
{
obj[i].value=obj[i-1].value;
c[i]=obj[i].value; }
}
return c;
}
function b()
{
var b=new Array();
var string="";
b=a();
for(var j=0;j<b.length;j++)
{
if(b[j]==undefined)
{
alert("dfs");
}
else
{
string=string+b[j]+",";
}
}
return string;
}
</script>
</head>
<body onload="formsubmit(1)">
<!--
<form name="form" id="form">
<table border="1">
<tr>
<td>
<input type="hidden" name="hiddenAblum" value="1">
<input type="checkbox" name="checkbox" onclick="b()" >
</td>
</tr>
<tr>
<td>
<input type="hidden" name="hiddeAblum" value="2">
<input type="checkbox" name="checkbox" onclick="b()">
</td></tr>
</table>
</form>
-->
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AlbumManagement;public partial class PersonalPicture : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
string UserID = Request["UserID"].ToString();
AlbumManagement.AlbumClass AlbumInfo = new AlbumManagement.AlbumClass();
//Response.Write(AlbumInfo.AlbumList(Request["UserID"].ToString().Trim()));
HttpContext.Current.Response.Write(AlbumInfo.AlbumList(Request["UserID"].ToString().Trim()));
//HttpContext.Current.Response.Write(AlbumInfo.AlbumList("52"));
Response.Flush();
Response.End();
}
}
if(xmlHttp.readyState==4)
{ alert(xmlHttp.statusText); var xmlobj=xmlHttp.responseXML;
alert(xmlHttp.responseXML.xml);是statusText引发了"Object Not Found", 在第一次看帖子时还以为是page not found,
LZ换成xmlHttp.status试试就应该好了,
而且,不能光检测 readyState,应当还要检测status,即:
if(xmlHttp.readyState==4 && xmlHttp.status == 200)
{
// your code here ...
}
status为200才能说明服务器正确返回了
如果是,把
if(xmlHttp.readyState==4)
{
alert(xmlHttp.statusText);
var xmlobj=xmlHttp.responseXML;
alert(xmlHttp.responseXML.xml);
//....
}
改成
if(xmlHttp.readyState==4)
{ alert("status:" + xmlHttp.status); var xmlobj=xmlHttp.responseXML;
alert("xml: " + xmlHttp.responseXML.xml);
//.........
}这样就能看出是哪一步出的问题了,如果这样改了有错,可能是第二步出错,不应当是第一步的
再次,Album_Table.getElementsByTagName("ALBUM_ID")[0].firstChild.data.data??
~~~~~
statusText返回值我用alert(xmlhttp.statusText)弹出来
.cs文件返回xml格式的内容
.data??
难道属性用错了吗