ʹÓà jQuery ¼ò»¯ Ajax ¿ª·¢
jQuery ÊÇÒ»¸öJavaScript ¿â£¬ËüÓÐÖúÓÚ¼ò»¯ JavaScript™ ÒÔ¼° Asynchronous JavaScript + XML (Ajax) ±à³Ì¡£ÓëÀàËÆµÄ JavaScript ¿â²»Í¬£¬jQuery ¾ßÓжÀÌصĻù±¾ÔÀí£¬¿ÉÒÔ¼ò½àµØ±íʾ³£¼ûµÄ¸´ÔÓ´úÂ롣ѧϰ jQuery »ù±¾ÔÀí£¬Ì½Ë÷ÆäÌØÐԺ͹¦ÄÜ£¬Ö´ÐÐһЩ³£¼ûµÄ Ajax ÈÎÎñ²¢ÕÆÎÕÈçºÎʹÓòå¼þÀ©Õ¹ jQuery¡£
jQuery ÊÇʲô£¿
Çë·ÃÎÊ Ajax ¼¼Êõ×ÊÔ´ÖÐÐÄ£¬ÕâÊÇÓÐ¹Ø Ajax ±à³ÌÄ£ÐÍÐÅÏ¢µÄһվʽÖÐÐÄ£¬°üÀ¨ºÜ¶àÎĵµ¡¢½Ì³Ì¡¢ÂÛ̳¡¢blog¡¢wiki ºÍÐÂÎÅ¡£ÈκΠAjax µÄÐÂÐÅÏ¢¶¼ÄÜÔÚÕâÀïÕÒµ½¡£
jQuery ÓÉ John Resig ´´½¨ÓÚ 2006 Äê³õ£¬¶ÔÓÚÈκÎʹÓà JavaScript ´úÂëµÄ³ÌÐòÔ±À´Ëµ£¬ËüÊÇÒ»¸ö·Ç³£ÓÐÓÃµÄ JavaScript ¿â¡£ÎÞÂÛÄúÊǸոսӴ¥ JavaScript ÓïÑÔ£¬²¢ÇÒÏ£Íû»ñµÃÒ»¸öÄܽâ¾öÎĵµ¶ÔÏóÄ£ÐÍ£¨Document Object Model£¬DOM£©½Å±¾ºÍ Ajax ¿ª·¢ÖÐһЩ¸´ÔÓÎÊÌâµÄ¿â£¬»¹ÊÇ×÷Ϊһ¸öÑá¾ëÁË DOM ½Å±¾ºÍ Ajax ¿ª·¢ÖÐÎÞÁĵÄÖظ´¹¤×÷µÄ×ÊÉî JavaScript ר¼Ò£¬jQuery ¶¼»áÊÇÄúµÄÊ×Ñ¡¡£
jQuery ÄÜ°ïÖúÄú±£Ö¤´úÂë¼ò½àÒ׶Á¡£ÄúÔÙÒ²²»±Ø±àд´ó¶ÑÖظ´µÄÑ»·´úÂëºÍ DOM ½Å±¾¿âµ÷ÓÃÁË¡£Ê¹Óà jQuery£¬Äú¿ÉÒÔ°ÑÎÕÎÊÌâµÄÒªµã£¬²¢Ê¹Óþ¡¿ÉÄÜ×îÉٵĴúÂëʵÏÖÄúÏëÒªµÄ¹¦ÄÜ¡£
ºÁÎÞÒÉÎÊ£¬jQuery µÄÔÀíÊǶÀÒ»ÎÞ¶þµÄ£ºËüµÄÄ¿µÄ¾ÍÊDZ£Ö¤´úÂë¼ò½à²¢¿ÉÖØÓᣵ±ÄúÀí½â²¢Ìå»áÕâÒ»ÔÀíºó£¬±ã¿ÉÒÔ¿ªÊ¼Ñ§Ï°±¾½Ì³ÌÁË£¬¿´¿´ jQuery ¶ÔÎÒÃǵıà³Ì·½Ê½ÓжàÉٸĽø°É¡£
»ØÒ³Ê×
һЩ¼òµ¥µÄ´úÂë¼ò»¯
ÏÂÃæÊÇÒ»¸ö¼òµ¥Ê¾Àý£¬Ëü˵Ã÷ÁË jQuery ¶Ô´úÂëµÄÓ°Ïì¡£ÒªÖ´ÐÐһЩÕæÕý¼òµ¥ºÍ³£¼ûµÄÈÎÎñ£¬±È·½ËµÎªÒ³ÃæµÄijһÇøÓòÖеÄÿ¸öÁ´½Ó¸½¼ÓÒ»¸öµ¥»÷£¨click£©Ê¼þ£¬Äú¿ÉÒÔʹÓô¿ JavaScript ´úÂëºÍ DOM ½Å±¾À´ÊµÏÖ£¬Èç Çåµ¥ 1 Ëùʾ¡£
Çåµ¥ 1. ûÓÐʹÓà jQuery µÄ DOM ½Å±¾
var external_links = document.getElementById('external_links');
var links = external_links.getElementsByTagName('a');
for (var i=0;i < links.length;i++) {
var link = links.item(i);
link.onclick = function() {
return confirm('You are going to visit: ' + this.href);
};
}
Çåµ¥ 2 ÏÔʾÁËʹÓà jQuery ʵÏÖµÄÏàͬµÄ¹¦ÄÜ¡£
Çåµ¥ 2. ʹÓÃÁË jQuery µÄ DOM ½Å±¾
$('#external_links a').click(function() {
return confirm('You are going to visit: ' + this.href);
});
ÊDz»ÊǺÜÉñÆ棿 ʹÓà jQuery£¬Äú¿ÉÒÔ°ÑÎÕÎÊÌâµÄÒªµã£¬Ö»ÈôúÂëʵÏÖÄúÏëÒ
Ïà¹ØÎĵµ£º
ÉÏ´«Ò³ÃæÖ»ÐèÒªÒ»¸öjsÒýÓúÍjsº¯ÊýµÄµ÷Ó㬼òµ¥·½±ã£¬²»Ó°ÏìÍøÒ³ÔÓв¼¾Ö¡£
ÏÂÔصØÖ·
µ÷ÓÃ˵Ã÷:
1.Ê×ÏÈÒýÓÃjsÎļþ
<script type="text/javascript" src="AienUpload/init.js"></script>
2.½«º¯Êýµ÷ÓÃ(showUpload(boxCtrl,inputCtrl,upPath,maxCount,fn);)°ó¶¨µ½HTMl¿Ø¼þʼþ£¬ÀýÈç
......
===============ÏÂÆAjax
================
ʮһ¡¢µÚʮһ¿Î ===¡· ʹÓÃXHR¶ÔÏó·¢ËͺͽÓÊÜÊý¾Ý
a.¼ÌÐøÉÏÃæ²½Öè
2)×¢²á»Øµ÷º¯Êý,ֻдº¯ÊýÃû³Æ(Èç¹û¼ÓÁËÀ¨ºÅ£¬ÄÇô¾Í°Ñº¯Êý·µ»ØÖµ×¢²á¸ø»Øµ÷º¯Êý)
xmlHttp.onreadystatechange = callback;
3)ÉèÖÃÁ¬½ÓÐÅÏ¢
//µÚÒ»²ÎÊýÊÇHttpÇëÇó·½Ê½£¬Ò»°ãÑ¡Ôñget¡¢pos ......
Ò» ÒýÌâ
ÈçºÎÈÃweb³ÌÐòÓÃÆðÀ´Ïñ×ÀÃæÓ¦ÓóÌÐòÒ»Ñù¼òµ¥£»
ÅÖ¿Í»§¶Ë£¿ÊÝ¿Í»§¶Ë£¿ÈçºÎÑ¡Ôñ£¿-----¿´ÐèÇ󣬿´Óû§µÄʹÓã¬Áé»îµ÷½Ú¡£
²»ÒªÉÁ˸£¬¿Õ°×Ò³³öÏÖ£¿
¶þ ³õʶAjax
1. AjaxÊÇÒ»¸ö¿Í»§¶Ë¼¼Êõ£¬²»ÂÛÄãÏÖÔÚʹÓúÎÖÖ·þÎñÆ÷¶Ë¼¼Êõ£¬¶¼ÄÜʹÓÃAjax£¬¶ø²»¹ÜʹÓõÄÊÇJava¡¢.NET¡¢Ruby¡¢PHP»¹ÊÇCGI¡ ......
1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//I ......
Ê×Ïȶ¼ÊÇʹÓÃVS.Net2005´´½¨Ò»¸ö ASP.Net AJAX-Enabled Web Application
1¡¢Ê¹ÓÃAJAXÖ±½Óµ÷Óúǫ́·½·¨£º
ºǫ́´úÂ룺
namespace AJAX1
{
public partial class _Default : System.Web.UI.Page
{
// ÐèÒª±êʶΪWebMethod ......