![]() |
#2
xinzheng2008-07-10 22:13
index.html代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www. <html xmlns="http://www. xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>test</title> <style type="text/css" media="screen">@import "css/main.css";</style> <script type="text/javascript" src="js/ajax.js"></script> </head> <body> <input type="button" value="aa" onclick="startRequest(33);"/> <input type="button" value="bb" onclick="startRequest(34);"/> <div id="ajax"></div> </body> </html> ajax.js代码: function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } } function startRequest(pro_type) { createXMLHttpRequest(); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.open("GET", "product.asp?pro_type="+pro_type+'&n='+Math.random(), true); xmlHttp.send(null); } function handleStateChange() { if(xmlHttp.readyState == 4) { if(xmlHttp.status == 200) { document.getElementById("ajax").innerHTML = xmlHttp.responseText; } } } product.asp代码: <%@codepage="65001"%> <!--#include file="inc/conn.asp" --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <% pro_type=Request("pro_type") strsql="select * from pro_list where pro_type="&pro_type&" " set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn, 1,1 %> <div class="aa"> <%do while not rs.eof%> <a href=product_view.asp?id=<%=rs("id")%> title=<%=rs("pro_name")%>><%=rs("spbh")%></a> <%rs.movenext loop%> <%rs.Close Set rs=Nothing conn.Close Set conn=Nothing %> </div> |
点index.html里的按钮用ajax加载cp.asp(读取access数据库数据),同样的代码!本机IIS环境测试是乱码,可传到服务器上却是中文(而且光打开cp.asp本机页是乱码,传到网上却是中文最上面一句是<%@codepage="65001"%>)?还有点按钮加载时用IE在数据显示前鼠标不停的跳动,firefox则不跳,这个问题不管是本机还是网上都存在,望指教!!!!!!!!