Ajax程序如下
<html>
<head>
<title>以Ajax方式显示数据</title>
<script src="jquery.min.js"></script>
<script>
$(function(){ //页面载入时执行
$.get("10-1.asp?d=54", function(data){
$("#disp").append(data);
alert(data); //仅作测试,看服务器端数据是否已传来
});
} )
</script>
</head>
<body><h2 align="center">以Ajax方式显示数据</h2>
<table border="1" width="100%" id="disp"><tr bgcolor="#e0e0e0">
<th>标题</th> <th>内容</th> <th>作者</th>
<th>email</th> <th>来自</th>
</tr></table></body>
</html> ASP程序如下:
<!--#include file="conn.asp"-->
<%
Response.CharSet = "GB2312"
Set rs=conn.Execute("Select top 4 * From lyb")
do while not rs.eof
response.Write "<tr><td>"&rs("title")&"</td>" response.Write "<td>"&rs("content")&"</td>"
response.Write " <td>"&rs("author") &"</td>"
response.Write " <td>"&rs("email")&"</td>"
response.Write "<td>"& rs("ip")&"</td></tr>"
rs.movenext
loop
%>PHP程序如下:
<?
header("Content-type: text/html; charset=gb2312");
include('conn.php');
$result=$conn->query("Select * From lyb limit 4 ");
while($row=$result->fetch_assoc()){
echo "<tr><td>".$row['title']."</td>";
echo "<td>".$row['content']."</td>";
echo " <td>".$row['author']."</td>";
echo " <td>".$row['email']."</td>";
echo "<td>".$row['ip']."</td></tr>";
}
?>只要换成php程序,则Ajax程序中表格中就不能加载输出的行(但用alert测试已传回表格行数据),而用ASP程序却能正常加载,以上是在IE 6浏览器中的情况,在Firefox浏览器中,ASP和PHP程序都正常。
这是否说明ASP的输出和PHP的输出并不完全相同呢?
<html>
<head>
<title>以Ajax方式显示数据</title>
<script src="jquery.min.js"></script>
<script>
$(function(){ //页面载入时执行
$.get("10-1.asp?d=54", function(data){
$("#disp").append(data);
alert(data); //仅作测试,看服务器端数据是否已传来
});
} )
</script>
</head>
<body><h2 align="center">以Ajax方式显示数据</h2>
<table border="1" width="100%" id="disp"><tr bgcolor="#e0e0e0">
<th>标题</th> <th>内容</th> <th>作者</th>
<th>email</th> <th>来自</th>
</tr></table></body>
</html> ASP程序如下:
<!--#include file="conn.asp"-->
<%
Response.CharSet = "GB2312"
Set rs=conn.Execute("Select top 4 * From lyb")
do while not rs.eof
response.Write "<tr><td>"&rs("title")&"</td>" response.Write "<td>"&rs("content")&"</td>"
response.Write " <td>"&rs("author") &"</td>"
response.Write " <td>"&rs("email")&"</td>"
response.Write "<td>"& rs("ip")&"</td></tr>"
rs.movenext
loop
%>PHP程序如下:
<?
header("Content-type: text/html; charset=gb2312");
include('conn.php');
$result=$conn->query("Select * From lyb limit 4 ");
while($row=$result->fetch_assoc()){
echo "<tr><td>".$row['title']."</td>";
echo "<td>".$row['content']."</td>";
echo " <td>".$row['author']."</td>";
echo " <td>".$row['email']."</td>";
echo "<td>".$row['ip']."</td></tr>";
}
?>只要换成php程序,则Ajax程序中表格中就不能加载输出的行(但用alert测试已传回表格行数据),而用ASP程序却能正常加载,以上是在IE 6浏览器中的情况,在Firefox浏览器中,ASP和PHP程序都正常。
这是否说明ASP的输出和PHP的输出并不完全相同呢?
所以 ie6 在 asp 下也不可能有正确结果
<tr><td><%= rs("title") %></td>
形式,则ie6 下也不正常了,但firefox始终是正常的,说明ie6下往table里插入内容多少都存在些问题
都不对,没显示应该是由于有乱码造成无法解析的错误var href='10-1.asp?d=54';
var params = {
type:'POST',
url:href,
dataType:'text',
success:function(data){
jQuery("#disp").append(data);
}
};
jQuery.ajax( params );
用这个试试,要保证2个页面的编码一致