jQuery 1.5 beta1³öÀ´ÁË£¬´Óѧϰ¸ú½øÉÏÀ´Ëµ£¬ÕâÒ»´ÎÒѾ±È½ÏÍíÁË£¨ÎÒ¾¹È»²»ÖªµÀ1.5ʲôʱºò³öµÄalpha£¬¾ÍÕâôbetaÁË£©¡£
Õâ¸ö1.5°æ±¾×î´óµÄ¸üÐÂÊÇAJAXµÄÍêÈ«ÖØд£¬ÌṩÁ˸üÇ¿µÄ¿ÉÀ©Õ¹ÐÔ¡£µ«ÊÇÊÜÖÆÓÚ¾«Á¦ºÍƪ·ù£¬¶ÔеÄAJAXµÄ·ÖÎö»¹ÊǷŵ½Ï»أ¬±¾ÆªÏȼòµ¥½éÉÜÒ»ÏÂϸ½Ú·½ÃæµÄ¸Ä½ø¡£
jQuery._DeferredºÍjQuery.Deferred
Ê×ÏȲ»µÃ²»ËµÕâÁ½¸öÐÂÉúÊÂÎÒòΪËûÃÇÊÇ×÷Ϊ»ù´¡ÉèÊ©´æÔÚ£¬²»°ÑÕâÁ½¸ö¶«Î÷½²Ã÷°×ÁË£¬ÓÐЩÎÊÌâ¸ù±¾Ã»°ì·¨½âÊÍ¡£
Ê×ÏÈ£¬jQuery.DeferredÊÇjQuery._DeferredµÄÔöÇ¿°æ£¬Òò´Ë¶ÔÓÚÕâ¸öÎÊÌ⣬´ÓjQuery._DeferredÈëÊÖ£¬¾ÍÄÜ˵Ã÷Ò»´ó°ëµÄÎÊÌâ¡£
ʲôÊÇDeferred£¿´Ó×ÖÃæÉÏ¿´£¬ÎҵĵÚÒ»·´Ó¦ÊÇ¡°ÑÓ³Ù¼ÓÔØ¡±£¬Ê××Öĸ´óдµÄÓ¦¸ÃÊÇ¡°ÀàÐÍ¡±µÄ¶¨Ò壬ËùÒÔÕâ´ó¸ÅÊÇÒ»¸ö¡°Í¸Ã÷ÌṩÑÓ³Ù¼ÓÔع¦ÄÜ¡±µÄÀàÐÍ°É¡£È»¶øʵ¼ÊÉÏ£¬ËäȻȷʵ´øÓÐÄÇôһµãµã¡°ÑÓ³Ù¡±µÄÒâ˼£¬Õâ¸ö¶«Î÷È´²»ÊÇÓÃÀ´ÊµÏÖÑÓ³Ù¼ÓÔصġ£
¼òµ¥À´Ëµ£¬jQuery._DeferredÊÇÒ»¸öº¯Êý¶ÓÁУ¬ËûµÄ×÷ÓÃÓÐÒÔϼ¸µã£º
- ±£´æÈô¸É¸öº¯Êý¡£
- ÔÚÌض¨µÄʱ¿Ì°Ñ±£´æ×ŵĺ¯ÊýÈ«²¿Ö´Ðеô¡£
- Ö´Ðйýºó£¬Ð½øÀ´µÄº¯Êý»áÁ¢¿ÌÖ´ÐС£
¸Ð¾õÊDz»ÊǺÍɶ¶«Î÷ºÜÏñ£¿¶Ô£¬jQueryµÄreadyº¯Êý¾ÍÊÇÕâÑùµÄÂß¼£¬Êµ¼ÊÖÐjQuery 1.5ÖеÄreadyº¯ÊýҲȷʵ±»¼Þ½Óµ½ÕâÉÏÃæÈ¥ÁË¡£
jQuery._DeferredÌṩÏÂÃæµÄ½Ó¿Ú£º
- done£ºfunction(fn1, fn2, ...)µÄÐÎʽ£¬ÓÃÓڰѺ¯ÊýÌí¼Óµ½¶ÓÁÐÖС£
- fire£ºfunction(context, args)µÄÐÎʽ£¬Ê¹ÓÃcontextÖ¸¶¨this¶ÔÏó£¬argsÖ¸¶¨²ÎÊý£¬µ÷ÓöÓÁÐÖÐËùÓк¯Êý¡£fire±»µ÷Óúó£¬_Deferred»á½øÈë isResolved״̬£¬Î´À´¶ÔdoneµÄµ÷Óò»»áÔÙ±£´æº¯Êý£¬¶øÊÇÖ±½Óµ÷Óú¯Êý¡£
- resolve£ºÏ൱ÓÚµ÷ÓÃfire(this, arguments)£¬Ò»¸ö¼ò»¯µÄ·½·¨¡£
- isResolved£ºÓÃÀ´ÅжÏ_DeferredÊÇ·ñÔÚisResolved״̬£¬¾ßÌå²Î¿¼Ç°ÃæµÄfireº¯ÊýµÄ½âÊÍ¡£
- cancel£ºÈ¡ÏûµôÕû¸ö¶ÓÁУ¬ÕâÑù²»¹ÜδÀ´ÊDz»ÊÇfire£¬¶ÓÁÐÖеĺ¯Êý¶¼²»»áÔÙ±»µ÷Óá£
˵Ã÷°×ÁËjQuery._Deferred£¬ÔÙÀ´¿´¿´jQuery.Deferred¡£Õâ¸ö¶«Î÷Æäʵ¾ÍÊÇ2¸ö_Deferred×é³ÉµÄ£¬µÚÒ»¸ö³ÆΪ deferred£¬ÓÃÓÚ±£¹Ü¡°Õý³£¡±×´Ì¬Ïµĺ¯Êý£»µÚ¶þ¸ö³ÆΪfailDeferred£¬ÓÃÓÚ±£¹Ü¡°³ö´í¡±×´Ì¬Ïµĺ¯Êý¡£Í¬Ê± jQuery.DeferredÌṩÁËһЩеĽӿڣº
- then£ºfunction(done, fail)µÄÐÎʽ£¬°ÑdoneÌí¼Ó½ødeferred£¬°ÑfailÌí¼Ó½øfailedDeferred¡£
- fail£ºÏ൱ÓÚfailDeferredµÄdoneº¯Êý¡£
- fireReject£ºÏ൱ÓÚfailDeferredµÄfireº¯Êý¡£
- reject£ºÏ൱ÓÚfailDeferredµÄresolveº¯Êý¡£
- isRejected£ºÏ൱ÓÚfailDeferredµÄisResolvedº¯Êý¡£
ͬʱjQuery.DeferredÈ¡ÏûÁËcancelº¯Êý¡£
ÄÇôÕâ¸öÊÇɶÓõÄÄØ£¿ÓС°Õý³£¡±ºÍ¡°³ö´í¡±2¸ö״̬£¬Í¬Ê±ÓÖÊÇÒì²½µÄ£¬ºÜÈÝÒ×¾ÍÄÜÏëµ½¡¡¶Ô£¬¸øAJAXÓõģ¬ÔÚÏÂһƪ·ÖÎöÖÐÔÙÏêϸ˵Ã÷¡£
jQuery.readyµÄ±ä»¯
ÒòΪÓÐÁËjQuery._DeferredÕâ¸ö¶«Î÷£¬jQuery.readyº¯Êý±ä³ÉÒÀÀµÓÚº¯Êý¶ÓÁУ¬¾ßÌåµÄ±ä»¯ÓУº
ÔÀ´µÄreadyList±äÁ¿ÒѾ²»ÔÙÊÇÒ»¸öÊý×飬¶ø±ä³ÉÁËjQuery._Deferred¶ÔÏó¡£
Ô±¾ÔÚDOMContentLoadedʱ£¬µ÷ÓÃreadListÖÐËùÓк¯ÊýµÄÂß¼£¬ÏÖÔÚҲʹÓÃÁËjQuery._DeferredÖУ¬ÔÀ´µÄ´úÂ룺
while ( (fn = ready[ i++ ]) ) {
fn.call( document, jQuery );
}
±ä³ÉÁË£º
readyList.fire( document , [ jQuery ] );
jQuery.parseXMLº¯Êý
ÐÂÔöÁ˾²Ì¬º¯ÊýjQuery.parseXML£¬ÓÃÓÚÌṩä¯ÀÀÆ÷¼æÈݵĴÓ×Ö·û´®×ªÎªXMLÎĵµµÄ¹¦ÄÜ¡£
¸Ãº¯ÊýµÄÂß¼ÍøÉÏÓкܶ࣬jQueryҲûÓÐÌرðµÄµØ·½£¬´óÖ·ÖΪÒÔÏÂ2ÖÖ£º
-
¶ÔÓÚ±ê×¼ä¯ÀÀÆ÷£¬Ê¹ÓÃDOMParser¶ÔÏó£º
var parser = new DOMParser(); var xml = parser.parseFromString(text, 'text/html');
-
¶ÔÓÚIE£¬Ê¹ÓÃMicrosoft.XMLDOM¶ÔÏó£º
var parser = new ActiveXObject('Microsoft.XMLDOM'); parser.async = 'false'; parser.loadXML(text); var xml = parser.documentElement;
data²¿·Ö
Ìí¼ÓÁËjQuery.hasDataº¯Êý£¬ÓÃÓÚÅжÏÒ»¸öÔªËØÊÇ·ñÓÐjQuery¸½¼ÓÉÏÈ¥µÄÊý¾Ý¡£
ÐÞ¸ÄÁËjQuery.expandoµÄʵÏÖ£¬ÔÚÔÀ´µ¥´¿µØÈ¡µ±Ç°Ê±¼äµÄ»ù´¡ÉÏ£¬Ìí¼ÓÁËÒ»¸öËæ»úÊý£º
expando = "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" );
ÕâÑù±£Ö¤ÔÚͬһʱ¼ä£¬ÒýÈë¶à¸öjQuery¸±±¾£¬Õ⼸¸ö¸±±¾Ö®¼äµÄexpando²»»áÏ໥³åÍ»£¬µ¼ÖÂÔªËØÉϵÄdata±äµÃ´íÂÒ¡£Ò»°ãÀ´Ëµ£¬ÊDz»»áÒýÈë¶à¸öjQuery¸±±¾µÄ£¬µ«ÊÇʹÓÃSealJSµÈµÄʱºò£¬ÅäÖò»µ±µÄ»°£¬Ò²ÊǺÜÈÝÒ׳öÏÖ´ËÀàÎÊÌâµÄ¡£
DOM²Ù×÷²¿·Ö
Ô±¾µÄhasClass¡¢addClass¡¢removeClassº¯Êý¶¼ÐèÒª½«ÔªËصÄclassÊôÐÔ·Ö¸ôΪÊý×飬ÔÚ1.4.4°æ±¾ÖУ¬Í¨¹ý\n»ò\t½øÐзָô£¬ÔÚ1.5ÖÐÔö¼ÓÁËÒ»¸ö\r£¬ÓÃÓÚ¶ÔÓ¦Windowsƽ̨ϵĻ»Ðзû£¨\r\n£©¡£
jQuery.fn.attrº¯Êý£¬1.4.4°æ±¾Öоܾø´ÓTextNodeºÍCommentNodeÉÏ»ñÈ¡ÊôÐÔ£¬ÔÚ1.5°æ±¾ÖÐÌí¼ÓÁËÒ»¸öAttributeNode£¨noteType == 2£©¡£
ÔÚ1.4.4°æ±¾ÖУ¬jQuery»áÔÚÒ³ÃæunloadµÄʱºòÇåÀíµôÓÉjQueryά»¤µÄËùÓÐDOMʼþ£¬ÕâÊÇΪÁ˱ÜÃâIEµÄÄÚ´æй¶ÎÊÌâ¡£µ«ÊÇÔÚ1.5ÖÐÕâÒ»¶Î´úÂë²»¼ûÁË£¬²»ÖªÊdzöÓÚʲô¿¼ÂÇ¡£
¶ÔÓÚIEÏÂʹÓÃcloneNode¸´Öƽڵ㣬»á½«Ê¼þÒ²Ò»Æð¸´ÖƹýÀ´µÄÎÊÌ⣬1.4.4ÖÐÊDzÉÈ¡¸´ÖÆinnerHTMLµÄ·½Ê½¸øÓè½â¾ö£¬¶øÔÚ1.5ÖÐÔò²ÉÄÉÁËmootoolsÍŶÓÌṩµÄ·½·¨£¬Ê¹ÓÃcloneFixAttributeº¯ÊýÐÞÕý¸ÃÎÊÌâ¡£
cloneFixAttributeº¯ÊýÃÇÓÚjQuery 1.5 beta1Ô´ÂëÎļþµÄ5388-5438ÐУ¬´¦ÀíIEµÄBUGµÄÔÀíºÜ¼òµ¥£¬µ±È»Ç°¶ËÀïһЩ¿´ËƼòµ¥µÄ¶«Î÷£¬¶¼ÊǺÜÄÑ·¢Ïֵģº
- IEÖÐÓиö½ÐclearAttributesµÄº¯Êý£¬»áÇå³ýµ½½ÚµãÉϵÄËùÓÐÊôÐÔ£¬Ë³±ã°ÑºÍʼþÏà¹ØµÄonclickÖ®ÀàµÄÊôÐÔҲȥµôÁË¡£ÔÚ¸´ÖƳöÀ´µÄ½ÚµãÉϵ÷ÓÃÕâ¸öº¯Êý£¬¾Í»á°ÑÊôÐÔÇåµÃ¸É¸É¾»¾»¡£
- IEÖл¹ÓÐÒ»¸ö½ÐmergeAttributesµÄº¯Êý£¬°ÑÒ»¸ö½ÚµãµÄÊôÐÔ¸´ÖƵ½ÁíÒ»¸ö½ÚµãÉÏ£¬µ«Ëû²»»á°ÑºÍʼþÏà¹ØµÄÊôÐÔ¸´ÖƹýÈ¥¡£ËùÒÔÔÙ°ÑÔʼ½Úµãµ÷ÓÃmergeAttributes£¬°ÑÊôÐÔÖØзŻظ´ÖƳöÀ´µÄ½ÚµãÉÏ£¬Õâ¾ÍÏ൱ÓÚÆðµ½ÁËÈ¥³ýʼþÏà¹ØÊôÐÔµÄ×÷Óá£
ÁíÍâcloneFixAttributeº¯Êý»¹´¦ÀíÁ˷dz£¶àIE6-8ÔÚcloneNodeÉϵļæÈÝÐÔÎÊÌ⣬·Ç³£ÖµµÃÏêϸÑо¿¡£
AJAX²¿·Ö
AJAXÒѾÍêÈ«ÖØдÁË£¬Ö»ÁôÏÂÒ»µã±ß±ß½Ç½Ç±£Áô×Å1.4.4°æ±¾µÄ·ç²É£¬ÕâÀïÖ»³éÈ¡Ò»²¿·Ö½øÐмòµ¥µÄ˵Ã÷¡£
ÔÀ´°æ±¾ÖÐ$.getºÍ$.postµÄʵÏַdz£ÏàËÆ£¬¾ßÌåÀ´Ëµ½öÓÐÒ»¸ömethodÅäÖÃÏͬ£¬Òò´ËÔÚ1.5°æ±¾Öб»ºÏ²¢ÆðÀ´ÁË£º
$.each(['get', 'post'], function(i, method) {
$[method] = function() { ... };
});
ajaxSetupº¯ÊýÏÖÔÚ¼ÓÁËÒ»ÐÐreturn this;
£¬¿ÉÒÔÁ´Ê½µ÷ÓÃÁË¡£
serializeArrayº¯ÊýÏÖÔÚͳһ½«valueÖеĻ»ÐзûÌæ»»³ÉWindowsµÄ·ç¸ñ£¨\r\n£©¡£
AJAXµÄ»Øµ÷º¯ÊýÖУ¬×÷Ϊ²ÎÊýµÄ¶ÔÏó²»ÔÙÊÇÔÉúµÄXMLHTTPRequest£¬¶øÊÇjQuery×Ô¼º·â×°µÄ³ÆΪjXHRµÄ¶ÔÏó£¬Õâ¸ö¶ÔÏóÌṩÁËXMLHTTPRequestµÄ³£Óýӿڡ£
Ô±¾¶ÔÓÚ¡°ÇëÇó³É¹¦¡±µÄä¯ÀÀÆ÷״̬Â룬³ý200-299ÒÔ¼°304Í⣬»¹ÓÐÒ»¸ö1223£¬À´×ÔÓÚIEµÄÒ»¸öBUG£¬»á½«204µÄ״̬Âë±ä³É 1223¡£ÏÖÔÚÒòΪÓÐÁËjXHR¶ÔÏó£¬Ï൱ÓÚÖмä¶àÁËÒ»²ã£¬Òò´Ë´ÓjXHR¶ÔÏó»ñÈ¡statusCode²»»á³öÏÖ1223µÄÇé¿ö£¬ÒѾ±»±ä»Ø204ÁË¡£
jQuery.ajaxº¯ÊýµÄÅäÖÃÏîÖжàÁËÒ»¸östatusCodeÏÆä½á¹¹Îªmap£¬ÓÃÓÚÖ¸¶¨·µ»ØÌض¨×´Ì¬ÂëʱµÄ»Øµ÷º¯Êý£¬´óÖÂÐÎʽÈçÏ£º
jQuery.ajax({
url: 'xxx',
statusCode: {
200: function() { ´¦ÀíÇëÇó³É¹¦ },
404: function() { ´¦ÀíÒ³ÃæδÕÒµ½ },
503: function() { ´¦ÀíService Unavailable }
}
});
ÔÙÌí¼ÓÁËÕâ¸ö»Øµ÷ºó£¬jQuery.ajaxº¯ÊýÒѾÓзdz£¶àµÄ»Øµ÷º¯Êý£¬Æä´¥·¢¹ý³ÌÈçÏ£º
- ¸ù¾Ý·µ»ØµÄ״̬Â룬´¥·¢success»òÕßerror»Øµ÷¡£
- ¸ù¾Ý״̬Â룬´¥·¢¶ÔÓ¦µÄstatusCode»Øµ÷¡£
- ´¥·¢complete»Øµ÷¡£
- ´¥·¢È«¾ÖajaxComplete»Øµ÷¡£
- Èç¹û´ËʱûÓÐÕýÔÚÖ´ÐеÄAJAX£¬´¥·¢È«¾ÖajaxStop»Øµ÷¡£
ÆäËûϸ½Ú
Èë¿Úº¯ÊýjQuery.fn.initÏÖÔÚ¶àÁËÒ»¸ö²ÎÊý£¬ÖµÊ¼ÖÕΪrootjQuery£¬ÓÃÓÚ¼ÓËÙinitº¯ÊýÖжÔrootjQuery±äÁ¿µÄ²éÕÒËٶȣ¨¼õÉÙÁËÒ»²ã×÷ÓÃÓò£©£º
//jQuery 1.5 beta1 Ô´Âë23ÐÐ
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
}
jQuery¶ÔÏóÖ§³Ö¼Ì³ÐÁË£¬¾ßÌåµÄÐÞ¸ÄÊǽ«¼¸´¦Ö±½Óµ÷ÓÃjQueryµÄ´úÂë¸ÄΪÁ˶Ôthis.constructorµÄµ÷Óãº
202ÐУºreturn this.constructor( context ).find( selector );
253ÐУºvar ret = this.constructor();
334ÐУºreturn this.prevObject || this.constructor(null);
ͬʱ»¹ÌṩÁËjQuery.subclassº¯ÊýÓÃÓÚ´´½¨Ò»¸ö¼Ì³Ð×ÔjQueryµÄÀàÐÍ£¬ÓÉÓÚ²»ÊǺܳ£ÓÃjQuery£¬¸üÊÇ´ÓÀ´Ã»ÓÐÓõ½¹ýÐèÒª¼Ì³ÐjQueryµÄÇé¿ö£¬Òò´ËÒ²²»·½±ã˵Õâ¸ö¹¦ÄܵÄ×÷ÓÃÓжà´ó¡£
ÍƼöÐÅÏ¢
- ÔÝÎ޼Ǽ
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- java urlÖØд¼¼Êõ(UrlReWriter)
- [ת]JavaµÄÊý×飨Array£©¡¢Vector¡¢ArrayLis....
- jsp»·¾³ÏÂajaxÂÒÂëÎÊÌâµÄ½â¾ö
- JSP¼¼Êõ Ö¸Áî ÂÒÂëÎÊÌâ ÔËÐÐÔÀíºÍ¾Å´óÒþʽ¶ÔÏó web¿ª·¢µÄË....
- JAVA ˮӡ ͼƬ ÎÄ×Ö
- java¶þ½øÖÆ£¬ÔÂë¡¢·´Âë¡¢²¹Â롢λÔËËã
- Java WebÓ¦ÓÃÆô¶¯¼ä¸ôÖ´ÐеijÌÐò
- jspÉú³ÉxmlÎļþʾÀý
- javaÖÐÀà±äÁ¿¡¢Àà·½·¨¡¢ÊµÀý±äÁ¿¡¢ÊµÀý·½·¨
- JSPÒ³ÃæµÄÎåÖÖÌøת·½·¨
ÆÀÂÛ