封装一个简单的Ajax函数
/**
* Ajax操作函数
*
* @param url -- 服务器端页面地址
* @param param -- 参数,类似 'user=123&id=100'
* @param method -- 请求服务器端的方法,Get和Post两种,默认是GET
* @param response -- 是否获取服务器端返回的结果,默认是true
*/
function ajax( url, param, method, response ){
//set default value
param = typeof(param)=='undefined' ? '' : param;
method = typeof(method)=='undefined' ? 'GET' : method;
response = typeof(response)=='undefined' ? true : response;
//get ajax object
var ajax = null;
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
ajax = null;
}
}
if (!ajax && typeof XMLHttpRequest!='undefined'){
ajax = new XMLHttpRequest();
}
if (!ajax){
alert("Get ajax object failed");
return false;
}
//send http request
var res = '';
if (method != 'GET'){
method = 'POST';
}
if (method == 'GET'){
ajax.open('GET', url + param, true);
ajax.onreadystatechange = function(){
if (ajax.readyState==4 && ajax.status==200){
res = ajax.responseText;
}
}
ajax.send(null);
}
if (method == "POST"){
ajax.open("POST", url, true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send(param);
ajax.onreadystatechange = function() {
if (ajax.readyState==4 && ajax.status==200) {
res = ajax.responseText;
}
}
}
if (response){
return res;
}
return null;
}
相关文档:
<style type="text/css">
<!--
.STYLE1 {
font-size: 24px;
font-weight: bold;
}
.STYLE2 {font-size: 36px}
-->
.mouseOut {
color: #000000;
}
.mouseOver {
&nb ......
首先检查Web.config文件里是否是如下代码:
打开VS2005创建新项目,选择ASP.NET AJAX项目,然后把该项目Web.config文件的内容全部复制到你报错的Web.config文件里。
如果这个办法未能解决办法请查看该项目根目录的Bin文件夹内是否有System.Web.Extensions.Design.dll、System.Web.Extensions.dll、A ......
+++++++++++++++++++++++Ajax
~~~~~~~~~~~~~~~~~~~~~~~~~~
======= Ajax 技术 ========
一、第一课 ===》 AJAX概述与IntelliJ安装
a.Ajax读法其实不是我们读的'阿假客斯',注意专业化。
b.王兴魁老师先讲实践再讲理论。
c.开发工具不再是eclipse了,因为ajax主要写javascript
d ......
AJAX 流行之后,总想好好学习一下。但是众多的框架实在难以选择。说明一下 ASP.NET AJAX 并不包括在 AJAX 框架之中。
刚开始学了 JQuqery, 众多的 $get(),...等等符号早已把我搞晕了。暂时就放弃了。
后来学习 ASP.NET AJAX ,在微软的领导下,逐渐由服务器端转向客户端编程。 激起我客户端编程的兴趣,
才想起学 ......