一个分页显示内容的页面使用了Ajax技术。请问如何获得它第二页的内容?

来源:百度知道 编辑:UC知道 时间:2024/05/27 16:19:15
普通的页我可以这样获取它的HTML代码:
WebClient WbClnt = new WebClient();
string html = WbClnt.DownloadString(url);
只要知道URL网址即可,但使用了Ajax的页面,点击了“下一页”。它的URL没变化,请问我如果获取它的第二页的Html内容?

http_request.open("POST",url,false);//url放你的提交路径
http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http_request.onreadystatechange=getCompMsg;// getCompMsg是你的回调方法
http_request.send("ciId=" + var1);//这里可以带参数

function getCompMsg()
{
if(http_request.readystate==4)
{
if(http_request.status==200){
document.getElementById("getAJAXvalue").value = http_request.responseText;//将返回的内容也就是你第2页的代码放到名为getAJAXvalue的元素中,你需要在你的页面中定义这么一个元素,拿到返回的html内容,下面你随便想做什么都行。
}
else{
document.getElementById("getAJAXvalue").value = "未接受到服务器数据,HTTP状态代码:" + http_request.status;
}
}
}

Ajax包含类似下面的一句,其中的url便是网址
xmlHttp.open("GET", url, false);