|
100Java金币
本帖最后由 websos 于 2014-3-23 23:24 编辑
测试Ajax读取网页源码,测试在IE内核浏览器可以使用,但是在谷歌、火狐内核浏览器就不能了,出现错误状态码0球解决,Jquery1.3 \1.6\1.9\2.0都测试过也是此类问题,下面贴代码:
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>Ajax无刷新测试</title>
<script type="text/javascript" src="jquery-2.1.0.min.js" mce_src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
postdata ();
});
});
function postdata(){
$.ajax({
url: "http://www.baidu.com",
type: "POST",
data:"" ,
contentType: "application/json; charset=utf-8",
timeout: 5000,
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(textStatus+' Error loading PHP document'+XMLHttpRequest.status);
},
success: function(msg){
$("#result").val(msg);
}
});
}
</script>
</head>
<body bgproperties="fixed" background="http://www.33.la/uploads/20121212BZXH/9248.jpg">
<p style="height:80px;"></p>
<div>
<table width="460" border="0" cellspacing="0" cellpadding="5" align="center">
<div align="center"> <input type="submit" name="button" id="button" value=" 提 交 " /> </div>
</table>
</div>
<div align="center">
<h5 style="color:#FF0000">结果:</h5>
<textarea rows="10" cols="44" id="result">
</textarea></div>
</body>
</html>
|
|