jQuery真的是一个不错的东西,感觉比prototype处理更加简单一些。
对object的事件绑定,尤其方便,比如你想把ID为"mBtn"的按钮绑定一个点击事件,
可以直接用$("#mBtn").click(funtion(){//here is fn});
关于jQuery大家可以直接去官网上面下载,另外jQuery的教程做的也是别具特色。
jQuery 官网及下载:http://wiki.jquery.org.cn/doku.php
jQuery教程:http://jquery.org.cn/api/cn/api_11.xml
以下是一个ajax的post例子。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My jQuery</title>
<meta name="Author" content="EdLongRen">
<script src="jquery-1.2.1.min.js"></script>
</head>
<body>
<div id="LoadingStatus" style="background:red;color:#fff;float:right;width:100px;display:none;border:1px solid #000;z-index:1000;">正在加载...</div>
<div id="msg" style="border:1px solid #ccc"></div>
<div><input type="button" value="Get" id="getBtn"></div>
<script language="JavaScript">
<!--
function myajax(ajaxurl,para){
$('#LoadingStatus').show();//显示进度条
$.ajax({
url: ajaxurl,
type: 'POST',
dataType: 'html',
timeout: 20000,//超时时间设定
data:para,//参数设置
error: function(){alert('error');$('#LoadingStatus').hide(2000);},//错误处理,隐藏进度条
success: function(html){
//加载成功处理
$('#LoadingStatus').hide(2000);
$('#msg').html(html);
}
});
}