关于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
相关文档:
我的春秋痴梦第二步:
写一个 通用的 对象 列表 ,还 包含 搜索和 属性过滤。
具体的效果是:
当新 业务 添加一个 表的时候,只需要在 对象模型里的 添加一个 model
后台几乎不需写代码。
(我是后台:激动人心!)
调用的对象,第几页,属性的 过滤 和搜索全是 前台的Ajax参数控制
(我是前台:#$!@#$%$^#$% ......
Ajax介绍
AJAX - 浏览器支持
AJAX 的要点是 XMLHttpRequest 对象。不同的浏览器创建 XMLHttpRequest 对象的方法是有差异的。IE 浏览器使用 ActiveXObject,而其他的浏览器使用名为 XMLHttpRequest 的 JavaScript 内建对象。如需针对不同的浏览器来创建此对象,我们要使用一条 "try and catch" 语句。
<script type="t ......
ajax提交表单
关键字: ajax
function ajaxSubmitForm(form, resultDivId) {
var elements = form.elements;// Enumeration the form elements
var element;   ......
参数:
options
返回值:
XMLHttpRequest
使用HTTP请求一个页面。
这是jQuery的低级AJAX实现。要查看高级抽象,见$.set、$.post等,这些方法更易于理解和使用。但是功能上有限制(例如,没有错
误处理函数)。
警告:如果数据类型指定为"script",那么POST自动转化为GET方法。(因为script会作为一个嵌入页 ......