{"id":99,"date":"2006-06-12T13:18:14","date_gmt":"2006-06-12T05:18:14","guid":{"rendered":"http:\/\/tmp.xujiwei.com\/blog\/?p=99"},"modified":"2010-01-28T23:50:46","modified_gmt":"2010-01-28T15:50:46","slug":"ajax-first-step","status":"publish","type":"post","link":"https:\/\/xujiwei.com\/blog\/2006\/06\/ajax-first-step\/","title":{"rendered":"AJAX\u521d\u4f53\u9a8c\u4e4b\u4e0a\u624b\u7bc7"},"content":{"rendered":"<p>AJAX\u662f\u8fd9\u4e24\u5e74\u86ee\u70ed\u7684\u4e1c\u897f\uff0c\u6211\u4e5f\u51d1\u51d1\u70ed\u95f9\uff0c\u524d\u4e9b\u5929\u53bb\u627e\u4e86\u4e9b\u6559\u7a0b\u5b66\u5b66\uff0c\u4e0b\u9762\u5c31\u6309\u6574\u4e2a\u5904\u7406\u8fc7\u7a0b\u628a\u81ea\u5df1\u5b66\u7684\u4e1c\u897f\u5199\u5199\uff0c\u4e0d\u8fc7\uff0c\u56e0\u4e3a\u662f\u521d\u5b66\uff0c\u6240\u4ee5\u6709\u9519\u8bef\u5c31\u8bf7\u89c1\u8c05\u5566\uff0c\u4e5f\u6b22\u8fce\u6307\u6b63\uff0cvipxjw#163.com\u3002<\/p>\n<p>PS.\u5199\u5b8c\u4e86\u4e4b\u540e\u770b\u4e86\u4e0b\uff0c\u7ed3\u679c\u518d\u6b21\u9a8c\u8bc1\u81ea\u5df1\u5199\u6559\u7a0b\u771f\u662f\u4e71\u5f97\u53ef\u4ee5\uff0c\u4e1c\u8bf4\u4e00\u5757\u897f\u8bf4\u4e00\u5757\uff0c\u6761\u7406\u4e0d\u592a\u6e05\u695a\u7684\u8bf4\uff1a\uff09\u3002<\/p>\n<p><strong>1.\u521b\u5efa\u00a0XMLHttpRequest\u00a0\u5bf9\u8c61<\/strong><\/p>\n<p>\u73b0\u5728\u7684\u6d4f\u89c8\u5668\u6709\u5f88\u591a\u79cd\uff0c\u521b\u5efa\u00a0XMLHttpRequest\u00a0\u7684\u65b9\u6cd5\u4e5f\u4e0d\u76f8\u540c\uff0c\u6240\u4ee5\u4e3a\u4e86\u517c\u5bb9\u5404\u79cd\u6d4f\u89c8\u5668\uff0c\u5728\u521b\u5efa\u00a0XMLHttpRequest\u00a0\u65f6\u4e5f\u5e94\u8be5\u8003\u8651\u5230\u5404\u79cd\u6d4f\u89c8\u5668\u7684\u60c5\u51b5\u3002\u76ee\u524d\u4e3b\u6d41\u7684\u6d4f\u89c8\u5668\u5728Windows\u4e0b\u6709IE\u3001Firefox\u53caOpera\uff0c\u6240\u4ee5\u6211\u4eec\u5199\u7684\u4ee3\u7801\u8981\u5c3d\u91cf\u517c\u5bb9\u8fd9\u51e0\u4e2a\u6d4f\u89c8\u5668\u3002\u5728\u53c2\u8003\u4e86\u4e00\u4e9b\u8d44\u6599\u540e\uff0c\u6211\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u6765\u521b\u5efa\u00a0XMLHttpRequest\u00a0\u5bf9\u8c61\uff1a<\/p>\n<blockquote>\n<div id=\"_mcePaste\">\n<div id=\"_mcePaste\">\/\/ \u5148\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\uff0c\u5e76\u8d4b\u521d\u503c\u4e3a false\uff0c\u65b9\u4fbf\u540e\u9762\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u521b\u5efa\u6210\u529f<\/div>\n<div id=\"_mcePaste\">var xmlObj = false;<\/div>\n<div id=\"_mcePaste\">\/\/ \u4f7f\u7528 try \u6765\u6355\u83b7\u521b\u5efa\u5931\u8d25\uff0c\u518d\u6362\u4e2a\u65b9\u6cd5\u6765\u521b\u5efa<\/div>\n<div id=\"_mcePaste\">try {<\/div>\n<div id=\"_mcePaste\">\/\/ \u5728 Mozilla \u4e2d\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u521b\u5efa XMLHttpRequest \u5bf9\u8c61<\/div>\n<div id=\"_mcePaste\">xmlObj=new XMLHttpRequest;<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">catch(e) {<\/div>\n<div id=\"_mcePaste\">try {<\/div>\n<div id=\"_mcePaste\">\/\/ \u5982\u679c\u4e0d\u6210\u529f\uff0c\u90a3\u4e48\u5c1d\u8bd5\u5728\u8f83\u65b0 IE \u91cc\u7684\u65b9\u5f0f<\/div>\n<div id=\"_mcePaste\">xmlObj=new ActiveXObject(\"MSXML2.XMLHTTP\");<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">catch(e2) {<\/div>\n<div id=\"_mcePaste\">try {<\/div>\n<div id=\"_mcePaste\">\/\/ \u5931\u8d25\u5219\u5c1d\u8bd5\u4f7f\u7528\u8f83\u8001\u7248\u672c IE \u91cc\u7684\u65b9\u5f0f<\/div>\n<div id=\"_mcePaste\">xmlObj=new ActiveXObject(\"Microsoft.XMLHTTP\");<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">catch(e3) {<\/div>\n<div id=\"_mcePaste\">\/\/ \u8fd8\u662f\u5931\u8d25\uff0c\u90a3\u4e48\u5c31\u8ba4\u4e3a\u521b\u5efa\u5931\u8d25\u2026\u2026<\/div>\n<div id=\"_mcePaste\">xmlObj=false;<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">\/\/ \u5982\u679c\u521b\u5efa XMLHttpRequest \u5bf9\u8c61\u5931\u8d25\uff0c\u90a3\u4e48\u63d0\u9192\u8bbf\u95ee\u8005\u8be5\u9875\u9762\u53ef\u80fd\u65e0\u6cd5\u6b63\u786e\u8bbf\u95ee<\/div>\n<div id=\"_mcePaste\">if (!xmlObj) {<\/div>\n<div id=\"_mcePaste\">alert(\"XMLHttpRequest init Failed!\");<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<\/div>\n<\/blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; font-style: normal; line-height: 21px; font-size: 14px;\"><strong>2.\u4f7f\u7528\u00a0XMLHttpRequest\u00a0\u6765\u83b7\u53d6\u00a0XML\u00a0\u6587\u6863<\/strong><\/span><\/div>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; font-style: normal; line-height: 21px; font-size: 14px;\"><strong><span style=\"font-weight: normal;\"><strong><span style=\"font-weight: normal;\">\u5728\u7528\u00a0XMLHttpRequest\u00a0\u6765\u83b7\u53d6\u00a0XML\u00a0\u9700\u8981\u6ce8\u610f\u8fd9\u4e2a\u6587\u6863\u5fc5\u9700\u548c\u81ea\u5df1\u5728\u540c\u4e00\u4e2a\u57df\u4e2d\uff0c\u6211\u7684\u7406\u89e3\u662f\u540c\u4e00\u4e2a\u57df\u540d\u4e4b\u4e0b\uff0c\u6216\u8005\u540c\u4e00\u76ee\u5f55\u4e4b\u4e2d\uff0c\u5982\u679c\u4e0d\u662f\u5c31\u4f1a\u51fa\u73b0\u201c\u62d2\u7edd\u8bbf\u95ee\u201d\u7684\u9519\u8bef\u3002\u5728\u672c\u5730\u9ad8\u5ea6\u65f6\uff0c\u4e5f\u5fc5\u9700\u8fd0\u884c\u4e00\u4e2a\u00a0Web\u00a0\u670d\u52a1\u5668\uff0c\u800c\u4e0d\u80fd\u76f4\u63a5\u5728\u6d4f\u89c8\u5668\u91cc\u6253\u5f00\u8fd9\u4e2a\u7f51\u9875\u3002<\/span><\/strong><\/span><\/strong><\/span><\/div>\n<blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; font-style: normal; line-height: 21px; font-size: 14px;\"><strong><span style=\"font-weight: normal;\"><strong><span style=\"font-weight: normal;\"><\/p>\n<div>\/\/ \u4f7f\u7528 open \u65b9\u6cd5\u6765\u6253\u5f00\u4e00\u4e2a\u8bf7\u6c42\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u67093\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8bf7\u6c42\u65b9\u5f0f\uff0c\u8bf7\u6c42\u6587\u4ef6\u7684URL\u53ca\u540c\u6b65\u65b9\u5f0f(?\u4e0d\u662f\u5f88\u6e05\u695a\u5177\u4f53\u53eb\u4ec0\u4e48\u6765\u7684:)<\/div>\n<div>\/\/ \u8bf7\u6c42\u65b9\u5f0f\u53ef\u4ee5\u662f GET\uff0cPOST\uff0cHEAD\u4e2d\u7684\u4e00\u79cd\uff0c\u56e0\u4e3a\u6211\u8981\u83b7\u53d6\u6587\u4ef6\uff0c\u6240\u4ee5\u7528 GET<\/div>\n<div>\/\/ \u8bf7\u6c42\u6587\u4ef6\u7684URL\uff0c\u76f4\u63a5\u7528\u76f8\u5bf9\u8def\u5f84\u5373\u53ef<\/div>\n<div>\/\/ \u540c\u6b65\u65b9\u5f0f\uff0c\u8868\u793a\u8bf7\u6c42\u53d1\u51fa\u540e\u662f\u7b49\u5f85\u56de\u5e94(false)\u8fd8\u662f\u7ee7\u7eed\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801(true)\uff0c\u5373\u6240\u8c13\u5f02\u6b65\u4e86\u3002AJAX\u7684\u7b2c\u4e00\u4e2aA\u5c31\u662f\u8868\u793a\u5f02\u6b65\u4e86\uff0c\u6240\u4ee5\u8fd9\u91cc\u7528 true<\/div>\n<div>xmlObj.open (\"GET\", \"sample.xml\", true);<\/div>\n<div>\/\/ \u56e0\u4e3a\u4f7f\u7528\u5f02\u6b65\u65b9\u5f0f\u6240\u4ee5\u8981\u5728 XMLHttpRequest \u5bf9\u8c61\u7684\u72b6\u6001\u6539\u53d8\u65f6\u505a\u76f8\u5e94\u7684\u5904\u7406<\/div>\n<div>xmlObj.onreadystatechange=function() {<\/div>\n<div>\/\/ \u5982\u679c XMLHttpRequest \u7684\u72b6\u6001\u4e3a4\uff0c\u5e94\u8be5\u662fready\u6765\u7684\uff0c\u90a3\u4e48\u7ee7\u7eed\u5904\u7406<\/div>\n<div>if(xmlObj.readyState==4) {<\/div>\n<div>\/\/ \u9700\u8981\u5224\u65ad\u8fd4\u56de\u72b6\u6001\u662f\u5426\u4e3a200 OK\uff0c\u6709\u4e9b\u60c5\u51b5\u5982\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u5c31\u4e3a\u8fd4\u56de404<\/div>\n<div>if(xmlObj.status==200) {<\/div>\n<div>\/\/ \u4e00\u5207OK\uff0c\u8c03\u7528\u5904\u7406\u8fc7\u7a0b<\/div>\n<div>DoMyXML();<\/div>\n<div>}<\/div>\n<div>}<\/div>\n<div>}<\/div>\n<div>\/\/ \u53d1\u9001\u8bf7\u6c42\uff0c\u56e0\u4e3a\u662fGET\uff0c\u6240\u4ee5send\u7684\u5185\u5bb9\u4e3anull<\/div>\n<div>xmlObj.send(null);<\/div>\n<p><\/span><\/strong><\/span><\/strong><\/span><\/div>\n<\/blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\"><strong>3.\u7528ASP\u6765\u521b\u5efaXML\u6587\u6863<span style=\"font-weight: normal;\">3.\u7528ASP\u6765\u521b\u5efaXML\u6587\u6863<\/span><\/strong><\/span><\/div>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\"><strong><span style=\"font-weight: normal;\">\u4e3a\u4e86\u52a8\u6001\u663e\u793a\u7684\u9700\u8981\uff0c\u5c31\u8981\u7528\u5230\u52a8\u6001\u7f51\u9875\u4e86\uff0c\u6211\u7528\u7684\u662fASP\u3002<\/span><\/strong><\/span><\/div>\n<blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\"><strong><span style=\"font-weight: normal;\"><\/p>\n<div>&lt;%<\/div>\n<div>' \u4fee\u6539\u5934\u6807\u8bc6\u6307\u660e\u8fd9\u662f\u4e00\u4e2aXML\u6587\u6863<\/div>\n<div>Response.ContentType=\"text\/xml\"<\/div>\n<div>' ......<\/div>\n<div>strXML=\"&lt;?xml versin=\"\"1.0\"\" encoding=\"\"gb2312\"\"?&gt;\"<\/div>\n<div>' \u8fd9\u91cc\u5c31\u6309XML\u7684\u8981\u6c42\u6765\u8f93\u51fa\u6570\u636e\u5e93\u91cc\u7684\u5185\u5bb9\u4e86<\/div>\n<div>strXML=strXML&amp;\".....\"<\/div>\n<div>' ......<\/div>\n<div>Response.Write(strXML)<\/div>\n<div>%&gt;<\/div>\n<p><\/span><\/strong><\/span><\/div>\n<\/blockquote>\n<div>\n<div><strong>4.\u5904\u7406XML\u6587\u6863<\/strong><\/div>\n<div>\u5728\u83b7\u53d6\u4e86XML\u6587\u6863\u4e4b\u540e\uff0c\u5c31\u8981\u4ece\u4e2d\u83b7\u53d6\u9700\u8981\u7684\u4e1c\u897f\u4e86\uff0c\u5047\u5982\u6211\u4ece\u670d\u52a1\u83b7\u53d6\u4e86\u4e0b\u9762\u7684XML\u6587\u6863\uff1a<\/div>\n<blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; font-style: normal; line-height: 21px; font-size: 14px;\"><\/p>\n<ul style=\"padding: 0px; margin: 0px;\">\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;?xml\u00a0version=\"1.0\"\u00a0encoding=\"gb2312\"?&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;root&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> &lt;item&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> &lt;title&gt;AJAX\u00a0Study&lt;\/title&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> &lt;content&gt;Study\u00a0AJAX&lt;\/content&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> &lt;\/item&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;\/root&gt;<\/li>\n<\/ul>\n<p><\/span><\/div>\n<\/blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\">\u6211\u8981\u7684\u662ftitle\u53cacontent\u7684\u5185\u5bb9\uff0c\u90a3\u4e48\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u505a\uff1a<\/span><\/div>\n<blockquote>\n<div><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\"><span style=\"font-style: normal;\"><\/p>\n<ul style=\"padding: 0px; margin: 0px;\">\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">function\u00a0DoMyXML()\u00a0{<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> var\u00a0xmlDoc,items,title,content;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> \/\/\u00a0\u5148\u4eceXMLHttpRequest\u5bf9\u8c61\u4e2d\u5f97\u5230XML\u6587\u6863<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> xmlDoc=xmlObj.responseXML;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> \/\/\u00a0\u518d\u5f97\u5230items<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> items=xmlDoc.getElementsByTagName(\"item\");<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> \/\/\u00a0\u6700\u540e\u6839\u636eTagName\u6765\u83b7\u53d6\u60f3\u8981\u7684\u5185\u5bb9<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> \/\/\u00a0\u5982\u679cXML\u6587\u6863\u91cc\u6709\u591a\u4e2aitem\uff0c\u53ef\u4ee5\u7528\u6570\u7ec4\u7684\u4e0b\u6807\u6765\u8868\u793a\u7b2c\u51e0\u4e2a<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> title=items[0].getElementsByTagName(\"title\")[0].firstChild.data;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"> content=items[0].getElementsByTagName(\"content\")[0].firstChild.data;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">}<\/li>\n<\/ul>\n<p><\/span><\/span><\/div>\n<\/blockquote>\n<p>\u597d\u4e86\uff0c\u73b0\u5728\u5df2\u7ecf\u5f97\u5230\u6211\u60f3\u8981\u7684\u4e1c\u897f\uff0c\u53ef\u4ee5\u628a\u5b83\u4eec\u663e\u793a\u51fa\u6765\u4e86\u3002<\/p>\n<p><strong>5.\u8f93\u51fa\u5904\u7406\u7ed3\u679c<\/strong><\/p>\n<p>\u5148\u5047\u5b9a\u6709\u4e00\u4e2a\u5982\u4e0b\u7684HTML\u6587\u6863\u7528\u6765\u663e\u793a\u60f3\u8981\u8f93\u51fa\u7684\u5185\u5bb9\uff1a<\/p>\n<blockquote><p><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; font-style: normal; line-height: 21px; font-size: 14px;\"><\/p>\n<ul style=\"padding: 0px; margin: 0px;\">\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;html&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;head&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;title&gt;AJAX\u00a0Study&lt;\/title&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;\/head&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;body&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;div\u00a0id=\"mydisplay\"&gt;&lt;\/div&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;\/body&gt;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">&lt;\/html&gt;<\/li>\n<\/ul>\n<p><\/span><\/p><\/blockquote>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\">\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2aID\u4e3amydisplay\u7684DIV\u5bb9\u5668\u7528\u6765\u663e\u793a\u8f93\u51fa\u5185\u5bb9\uff0c\u597d\u4e86\uff0c\u518d\u8f6c\u5230JS\uff1a<\/span><\/li>\n<blockquote>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\"><span style=\"font-style: normal;\">\n<ul style=\"padding: 0px; margin: 0px;\">\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">\/\/...\u63a5DoMyXML;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">\/\/content=items[0].....;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">var\u00a0strHTML;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">\/\/\u00a0\u5148\u7ec4\u7ec7\u597d\u8981\u663e\u793a\u7684\u5185\u5bb9<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">strHTML=\"Item\u00a0title:\u00a0\"\u00a0+\u00a0title\u00a0+\u00a0\"&lt;br\u00a0\/&gt;Item\u00a0content:\u00a0\"\u00a0+\u00a0content;<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">\/\/\u00a0\u83b7\u53d6\u76ee\u6807\u5bb9\u5668\uff0c\u518d\u8bbe\u7f6e\u5b83\u7684innerHTML\u4e3a\u8981\u663e\u793a\u7684\u5185\u5bb9<\/li>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\">document.getElementById(\"mydisplay\").innerHTML=strHTML;<\/li>\n<\/ul>\n<p><\/span><\/span><\/li>\n<\/blockquote>\n<li style=\"list-style-type: none; list-style-position: initial; list-style-image: initial; background-color: transparent; padding: 0px; margin: 0px; border: initial none initial;\"><span style=\"color: #333333; font-family: Corbel, \u5fae\u8f6f\u96c5\u9ed1, Verdana, Arial, sans-serif; line-height: 21px; font-size: 14px;\">OK\uff0c\u8fd9\u4e9b\u5dee\u4e0d\u591a\u662f\u7f16\u5199AJAX\u7a0b\u5e8f\u7684\u57fa\u7840\uff0c\u5177\u4f53\u7528\u5c31\u770b\u4e2a\u4eba\u53d1\u6325\u4e86\uff0c\u5f53\u7136AJAX\u5e76\u4e0d\u53ea\u8fd9\u4e9b\uff0c\u8fd8\u6709\u5982\u679cPOST\u65b9\u6cd5\u53d1\u9001\u6570\u636e\u7b49\uff0c\u4e0d\u8fc7\u8fd9\u4e2a\u8fd8\u6ca1\u5b66\u8fc7\uff0c\u6240\u4ee5\u53ea\u80fd\u8bb2\u8fd9\u4e9b\u4e86^_^\u3002\u8fd8\u662f\u90a3\u53e5\u8bdd\uff0c\u56e0\u4e3a\u662f\u521d\u5b66\uff0c\u6709\u9519\u8bef\u5728\u6240\u96be\u514d\uff0c\u6b22\u8fce\u6307\u6b63\u3002<\/span><\/li>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>AJAX\u662f\u8fd9\u4e24\u5e74\u86ee\u70ed\u7684\u4e1c\u897f\uff0c\u6211\u4e5f\u51d1\u51d1\u70ed\u95f9\uff0c\u524d\u4e9b\u5929\u53bb\u627e\u4e86\u4e9b\u6559\u7a0b\u5b66\u5b66\uff0c\u4e0b\u9762\u5c31\u6309\u6574\u4e2a\u5904 &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/xujiwei.com\/blog\/2006\/06\/ajax-first-step\/\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[68,28,67],"_links":{"self":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/99"}],"collection":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":0,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}