{"id":89,"date":"2014-12-06T12:53:50","date_gmt":"2014-12-06T04:53:50","guid":{"rendered":"http:\/\/miku.host.smartgslb.com\/?p=89"},"modified":"2014-12-06T12:53:50","modified_gmt":"2014-12-06T04:53:50","slug":"jquery%e4%b8%ad%e7%9a%84%e9%93%be%e5%bc%8f%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/sora.sound.moe\/?p=89","title":{"rendered":"jQuery\u4e2d\u7684\u94fe\u5f0f\u64cd\u4f5c"},"content":{"rendered":"<p>\u672c\u5468\u7684\u65e5\u5e38\u2026\u2026\u665a\u4e0a\u518d\u53d1\uff0c\u8fd9\u4e0d\u662f\u65e5\u5e38\u2026\u2026<\/p>\n<p>\u6211\u4eec\u90fd\u9020\uff0c\u5728JavaScript\u4e2d\u901a\u8fc7\u4e0b\u9762\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u505a\u5230\u94fe\u5f0f\u64cd\u4f5c\u3002<\/p>\n<pre class=\"lang:js decode:true \">function example(){\n    \/\/code block\n    return this\n}<\/pre>\n<p>\u90a3\u4e48\u2026\u2026\u5728\u5947\u6280\u6deb\u5de7\u7684jQuery\u4e2d\u5c31\u66f4\u591a\u4e86\u2026\u2026<strong>\u4ee5\u4e0b\u5c31\u5f53\u662f\u5b66\u4e60\u7b14\u8bb0\u5427 \u83ca\u82e3\u4eec\u8bf7\u4e0d\u8981\u5410\u69fdQAQ<\/strong><!--more--><\/p>\n<p>jQuery\u4e2d\u795e\u5947\u7684$\u64cd\u4f5c\u7b26\uff0c\u80fd\u5e72\u7684\u4e8b\u597d\u591a\u5440\u2026\u2026\u4e0d\u4ec5\u53ef\u4ee5\u8fdb\u884c\u5143\u7d20\u7684\u7b5b\u9009\uff0c\u8fd8\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u5143\u7d20(\u5982\u4e0b\u56fe)\u2026\u2026\u90a3\u4e48\u673a\u4f1a\u6765\u4e86\u3002<\/p>\n<p><a href=\"https:\/\/sora.sound.moe\/wp-content\/uploads\/2014\/12\/QQ\u56fe\u724720141206123039.png\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-91 aligncenter\" src=\"https:\/\/sora.sound.moe\/wp-content\/uploads\/2014\/12\/QQ\u56fe\u724720141206123039.png\" alt=\"QQ\u56fe\u724720141206123039\" width=\"186\" height=\"72\" \/><\/a><\/p>\n<p>\u5047\u5982\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5143\u7d20\u5e76\u4e34\u65f6\u7684\u8d4b\u4e88\u5176\u4e00\u4e9b\u5c5e\u6027\uff0c\u90a3\u4e48\u94fe\u5f0f\u64cd\u4f5c\u5c31\u5f88\u597d\u73a9\u5566\u2026\u2026\u8fd9\u91cc\u6709\u4e00\u4e2a\u5c0f\u4f8b\u5b50\u3002<\/p>\n<pre class=\"lang:js decode:true\">$(\"div#example\").append(\n\t$(\"&lt;div&gt;\").attr({\"id\":\"examplechild\",\"title\":\"some text\"})\n\t          .css({\"display\":\"none\"})\n                  .text('233');\n);\n\/\/\u76f8\u5f53\u4e8e\n$(\"div#example\").append(\"&lt;div&gt;&lt;\/div&gt;\");\n$(\"div#example div:last\").attr({\"id\":\"examplechild\",\"title\":\"some text\"});\n$(\"div#examplechild\").css({\"display\":\"none\"});\n$(\"div#examplechild\").text('233');\n<\/pre>\n<p>QAQ\u6211\u672c\u6765\u662f\u5bf9\u9f50\u7684\u2026\u2026<\/p>\n<p>\u8fd9\u4e0d\u4f18\u96c5?\u53ef\u80fd\u5427\u2026\u2026<\/p>\n<p>jQuery\u8fd8\u6709\u4e2a\u5f88\u5389\u5bb3\u7684\u4e1c\u897f\u53eb.done() \u53ef\u4ee5\u5728\u4e00\u4e2aDeferred\u5bf9\u8c61\u6267\u884c\u5b8c\u6210\u540e\u94fe\u5f0f\u8c03\u7528\u3002<\/p>\n<p>\u7ed9\u4e2ajQuery\u5b98\u65b9\u4f8b\u5b50<\/p>\n<pre class=\"lang:js decode:true \">$.get(\"test.php\").done(function() {\n  alert(\"$.get succeeded\");\n});<\/pre>\n<p>\u914d\u5408.when()\u5c31\u66f4\u9177\u70ab\u4e86\uff0c\u57fa\u672cajax\u961f\u5217\u95ee\u9898\u5c31\u89e3\u51b3\u4e86\u2026\u2026<\/p>\n<pre class=\"lang:js decode:true \">$.when($.ajax(\"\/page1.php\"), $.ajax(\"\/page2.php\")).done(function(a1,  a2){\n  \/* a1 and a2 are arguments resolved for the\n      page1 and page2 ajax requests, respectively *\/\n  var jqXHR = a1[2]; \/* arguments are [ \"success\", statusText, jqXHR ] *\/\n  if ( \/Whip It\/.test(jqXHR.responseText) ) {\n    alert(\"First page has 'Whip It' somewhere.\");\n  }\n});<\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u7684\u4f5c\u7528\u662f\u5f53\u4e24\u4e2aajax\u8bf7\u6c42\u90fd\u6210\u529f\u65f6\u6267\u884c.done()\u4e2d\u7684callback function<\/p>\n<p>\u5982\u679c\u60f3\u65e0\u8bba\u5982\u4f55\u90fd\u6267\u884ccallback function\u7684\u8bdd\uff0c\u628a.done()\u6362\u6210.always()\u5c31\u884c\u5566\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u5173\u4e8e\u5ef6\u8fdf\u5bf9\u8c61\u7684\u8bf4\u660e\uff1ahttp:\/\/jquery.bootcss.com\/category\/deferred-object\/<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u5468\u7684\u65e5\u5e38\u2026\u2026\u665a\u4e0a\u518d\u53d1\uff0c\u8fd9\u4e0d\u662f\u65e5\u5e38\u2026\u2026 \u6211\u4eec\u90fd\u9020\uff0c\u5728JavaScript\u4e2d\u901a\u8fc7\u4e0b\u9762\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u505a\u5230\u94fe\u5f0f\u64cd\u4f5c\u3002  &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/sora.sound.moe\/?p=89\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cjQuery\u4e2d\u7684\u94fe\u5f0f\u64cd\u4f5c\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"twentyseventeen-featured-image":false,"twentyseventeen-thumbnail-avatar":false},"uagb_author_info":{"display_name":"Sora","author_link":"https:\/\/sora.sound.moe\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":"\u672c\u5468\u7684\u65e5\u5e38\u2026\u2026\u665a\u4e0a\u518d\u53d1\uff0c\u8fd9\u4e0d\u662f\u65e5\u5e38\u2026\u2026 \u6211\u4eec\u90fd\u9020\uff0c\u5728JavaScript\u4e2d\u901a\u8fc7\u4e0b\u9762\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u505a\u5230\u94fe\u5f0f\u64cd\u4f5c\u3002 &hellip;","_links":{"self":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/89"}],"collection":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":0,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}