关于jquery1.3.1,IE7,IE8中无法使用ajax的讨论?
大家好,最近使用jquery的ajax功能,但是发现$.ajax()方法不能提交到后台,我是用的是IE7,
其他方法如get和post没有试过,但由api所知底层都是用ajax方法来实现的。
通过查看源码发现
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup
xhr:function(){
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
},
以下是这个jquery的源码的版本声明
/*!
* jQuery JavaScript Library v1.3.1
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-01-21 20:42:16 -0500 (Wed, 21 Jan 2009)
* Revision: 6158
*/
上述xhr的创建代码位置大概是行数为3259的位置,
通过一个html打印“window.ActiveXObject ”的结果可以知道IE6、IE7和IE8都是返回的true,
测试的html源码为(同一个目录下有一个名为index.jsp页面,内容无所谓。)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript">
$(function (){
$.ajax({
url:"index.jsp",
success:function(){alert("success")},
error:function(){alert("error")}
});
//$("div").append("<font color='red'>window.ActiveXObject:</font>");
//$("div").append((window.ActiveXObject?"true":"false"));
&nbs
相关文档:
现在如果你问别人“最近两年在Web开发领域最火的技术是什么”,Ajax这个词应该能占据一席之地。确实,自从05年底被提出,Ajax技术就以难以想象的速度迅速红遍大江南北,受到无数Web开发人员的青睐和追捧。而各种平台下的Ajax框架更是如雨后春笋般向外冒,以至于连微软这样软件业的巨头也迫不及待推出自己的框架&m ......
$.ajax({
type: "post",
url: loginUrl,
data: "username=" +uname + "&password=" +pwd,
async: ......
Web 2.0 一瞥
在深入研究代码之前首先看看最近的观点 —— 一定要十分清楚 Web 2.0 这个概念。听到 Web 2.0 这个词的时候,应该首先问一问 “Web 1.0 是什么?” 虽然很少听人提到 Web 1.0,实际上它指的就是具有完全不同的请求和响应模型的传统 Web。比如,到 Amazon.com 网站上点击一个按钮或者输入 ......