{"id":101524,"date":"2026-09-07T00:35:39","date_gmt":"2026-09-06T16:35:39","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/101524.html"},"modified":"2026-09-07T00:35:39","modified_gmt":"2026-09-06T16:35:39","slug":"js-ajax%e5%ae%8c%e5%85%a8%e6%8c%87%e5%8d%97%ef%bc%88%e4%ba%8c%ef%bc%89%ef%bc%9aaxios%e4%ba%94%e7%a7%8d%e8%af%b7%e6%b1%82%e6%96%b9%e6%b3%95%e3%80%81%e8%b7%a8%e5%9f%9f%e8%a7%a3%e5%86%b3%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/101524.html","title":{"rendered":"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u672c\u6587\u662fAJAX\u7cfb\u5217\u7684\u7b2c\u4e8c\u7bc7&#xff0c;\u6df1\u5165\u8bb2\u89e3Axios\u7684\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5&#xff08;GET\/POST\/PUT\/PATCH\/DELETE&#xff09;\u3001\u5168\u5c40\u914d\u7f6e\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848&#xff08;JSONP\u4e0eCORS&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218\u6848\u4f8b\u4e32\u8054\u6240\u6709\u77e5\u8bc6\u70b9\u3002\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9&#xff0c;\u4f60\u5c06\u80fd\u591f\u72ec\u7acb\u5b8c\u6210\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001Axios\u57fa\u7840\u56de\u987e<\/h3>\n<h4>1.1 \u5f15\u5165Axios<\/h4>\n<p>&lt;script src&#061;&#034;..\/js\/axios.js&#034;&gt;&lt;\/script&gt;<\/p>\n<h4>1.2 \u4e09\u79cd\u8bf7\u6c42\u5904\u7406\u65b9\u5f0f<\/h4>\n<table>\n<tr>\n<p>\u65b9\u5f0f<\/p>\n<p>\u5199\u6cd5<\/p>\n<p>\u9002\u7528\u573a\u666f<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>Promise\u94fe\u5f0f\u8c03\u7528\u200b<\/p>\n<\/td>\n<td>\n<p>.then().catch()<\/p>\n<\/td>\n<td>\n<p>\u7b80\u5355\u7684\u5f02\u6b65\u5904\u7406<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u56de\u8c03\u51fd\u6570\u5f62\u5f0f\u200b<\/p>\n<\/td>\n<td>\n<p>.then(\u6210\u529f\u56de\u8c03, \u5931\u8d25\u56de\u8c03)<\/p>\n<\/td>\n<td>\n<p>\u9700\u8981\u5206\u522b\u5904\u7406\u6210\u529f\u548c\u5931\u8d25<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>async\/await\u200b<\/p>\n<\/td>\n<td>\n<p>try{ await } catch(error){}<\/p>\n<\/td>\n<td>\n<p>\u63a8\u8350&#xff0c;\u4ee3\u7801\u6700\u7b80\u6d01<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\/\/ \u65b9\u5f0f\u4e00&#xff1a;Promise\u94fe\u5f0f\u8c03\u7528<br \/>\naxios.get(&#034;http:\/\/localhost:3002\/user&#034;)<br \/>\n    .then((res) &#061;&gt; { console.log(res.data); })<br \/>\n    .catch((err) &#061;&gt; { console.log(err.message); });<\/p>\n<p>\/\/ \u65b9\u5f0f\u4e8c&#xff1a;\u56de\u8c03\u51fd\u6570\u5f62\u5f0f<br \/>\naxios.get(&#034;http:\/\/localhost:3002\/user&#034;).then(<br \/>\n    (res) &#061;&gt; { console.log(res.data); },<br \/>\n    (err) &#061;&gt; { console.log(err); }<br \/>\n);<\/p>\n<p>\/\/ \u65b9\u5f0f\u4e09&#xff1a;async\/await&#xff08;\u63a8\u8350&#xff09;<br \/>\nasync function getData() {<br \/>\n    try {<br \/>\n        let res &#061; await axios.get(&#034;http:\/\/localhost:3002\/user&#034;);<br \/>\n        console.log(res.data);<br \/>\n    } catch (error) {<br \/>\n        console.log(error);<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>\u4e8c\u3001Axios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u8be6\u89e3<\/h3>\n<h4>2.1 GET\u8bf7\u6c42 \u2014 \u83b7\u53d6\u6570\u636e<\/h4>\n<p>\/\/ \u57fa\u672c\u8bf7\u6c42<br \/>\nlet res &#061; await axios.get(&#034;http:\/\/localhost:3001\/list&#034;);<\/p>\n<p>\/\/ \u5e26\u53c2\u6570\u67e5\u8be2 &#8211; \u65b9\u5f0f\u4e00&#xff1a;URL\u62fc\u63a5<br \/>\nlet res &#061; await axios.get(&#034;http:\/\/localhost:3001\/list?name&#061;\u5b59\u609f\u7a7a&#034;);<\/p>\n<p>\/\/ \u5e26\u53c2\u6570\u67e5\u8be2 &#8211; \u65b9\u5f0f\u4e8c&#xff1a;params\u5bf9\u8c61&#xff08;\u63a8\u8350&#xff09;<br \/>\nlet res &#061; await axios.get(&#034;http:\/\/localhost:3001\/list&#034;, {<br \/>\n    params: {<br \/>\n        id: 4<br \/>\n    }<br \/>\n});<\/p>\n<h4>2.2 POST\u8bf7\u6c42 \u2014 \u65b0\u589e\u6570\u636e<\/h4>\n<p>let obj &#061; {<br \/>\n    id: &#043;new Date(),   \/\/ \u4f7f\u7528\u65f6\u95f4\u6233\u4f5c\u4e3a\u552f\u4e00ID<br \/>\n    name: this.inp.value,<br \/>\n    age: 2000,<br \/>\n    address: &#034;\u5f85\u5b9a&#034;<br \/>\n};<\/p>\n<p>await axios.post(&#034;http:\/\/localhost:3001\/list&#034;, obj);<\/p>\n<h4>2.3 PUT\u8bf7\u6c42 \u2014 \u5b8c\u6574\u66f4\u65b0<\/h4>\n<p>PUT\u8bf7\u6c42\u4f1a\u7528\u65b0\u6570\u636e\u5b8c\u5168\u66ff\u6362\u65e7\u6570\u636e&#xff0c;\u672a\u6307\u5b9a\u7684\u5b57\u6bb5\u4f1a\u88ab\u6e05\u7a7a\u3002<\/p>\n<p>\/\/ \u66f4\u65b0id\u4e3a1\u7684\u8bb0\u5f55&#xff0c;\u53ea\u4fdd\u7559name\u5b57\u6bb5<br \/>\nawait axios.put(&#034;http:\/\/localhost:3001\/list\/1&#034;, {<br \/>\n    name: this.inpEdit.value<br \/>\n});<\/p>\n<h4>2.4 PATCH\u8bf7\u6c42 \u2014 \u90e8\u5206\u66f4\u65b0<\/h4>\n<p>PATCH\u8bf7\u6c42\u53ea\u66f4\u65b0\u6307\u5b9a\u7684\u5b57\u6bb5&#xff0c;\u5176\u4ed6\u5b57\u6bb5\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n<p>\/\/ \u66f4\u65b0id\u4e3a2\u7684\u8bb0\u5f55&#xff0c;\u53ea\u4fee\u6539name\u5b57\u6bb5<br \/>\naxios.patch(&#034;http:\/\/localhost:3001\/list\/2&#034;, {<br \/>\n    name: this.inpEdit.value<br \/>\n});<\/p>\n<h4>2.5 DELETE\u8bf7\u6c42 \u2014 \u5220\u9664\u6570\u636e<\/h4>\n<p>let id &#061; this.inpDel.value;<br \/>\naxios.delete(&#096;\/list\/${id}&#096;);<\/p>\n<h4>2.6 \u4e94\u79cd\u65b9\u6cd5\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\n<p>\u65b9\u6cd5<\/p>\n<p>\u529f\u80fd<\/p>\n<p>\u8bf7\u6c42\u4f53<\/p>\n<p>\u5e42\u7b49\u6027<\/p>\n<p>\u9002\u7528\u573a\u666f<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>GET\u200b<\/p>\n<\/td>\n<td>\n<p>\u83b7\u53d6\u6570\u636e<\/p>\n<\/td>\n<td>\n<p>\u274c \u65e0<\/p>\n<\/td>\n<td>\n<p>\u2705 \u662f<\/p>\n<\/td>\n<td>\n<p>\u67e5\u8be2\u5217\u8868\u3001\u8be6\u60c5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>POST\u200b<\/p>\n<\/td>\n<td>\n<p>\u65b0\u589e\u6570\u636e<\/p>\n<\/td>\n<td>\n<p>\u2705 \u6709<\/p>\n<\/td>\n<td>\n<p>\u274c \u5426<\/p>\n<\/td>\n<td>\n<p>\u6dfb\u52a0\u65b0\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>PUT\u200b<\/p>\n<\/td>\n<td>\n<p>\u5b8c\u6574\u66f4\u65b0<\/p>\n<\/td>\n<td>\n<p>\u2705 \u6709<\/p>\n<\/td>\n<td>\n<p>\u2705 \u662f<\/p>\n<\/td>\n<td>\n<p>\u66ff\u6362\u6574\u6761\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>PATCH\u200b<\/p>\n<\/td>\n<td>\n<p>\u90e8\u5206\u66f4\u65b0<\/p>\n<\/td>\n<td>\n<p>\u2705 \u6709<\/p>\n<\/td>\n<td>\n<p>\u2705 \u662f<\/p>\n<\/td>\n<td>\n<p>\u4fee\u6539\u90e8\u5206\u5b57\u6bb5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>DELETE\u200b<\/p>\n<\/td>\n<td>\n<p>\u5220\u9664\u6570\u636e<\/p>\n<\/td>\n<td>\n<p>\u274c \u65e0<\/p>\n<\/td>\n<td>\n<p>\u2705 \u662f<\/p>\n<\/td>\n<td>\n<p>\u5220\u9664\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e09\u3001Axios\u5168\u5c40\u914d\u7f6e<\/h3>\n<h4>3.1 \u57fa\u672c\u914d\u7f6e\u9879<\/h4>\n<p>\/\/ \u914d\u7f6e\u5168\u5c40\u7684\u8d85\u65f6\u65f6\u957f&#xff08;\u5355\u4f4d&#xff1a;\u6beb\u79d2&#xff09;<br \/>\naxios.defaults.timeout &#061; 2000;<\/p>\n<p>\/\/ \u914d\u7f6e\u5168\u5c40\u7684\u57fa\u672cURL<br \/>\naxios.defaults.baseURL &#061; &#034;http:\/\/localhost:3001&#034;;<\/p>\n<h4>3.2 \u4f7f\u7528\u5168\u5c40\u914d\u7f6e\u540e\u7684\u8bf7\u6c42<\/h4>\n<p>\u914d\u7f6ebaseURL\u540e&#xff0c;\u8bf7\u6c42\u8def\u5f84\u53ef\u4ee5\u7b80\u5199\u4e3a\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n<p>\/\/ \u914d\u7f6e\u524d<br \/>\nawait axios.get(&#034;http:\/\/localhost:3001\/list&#034;);<br \/>\nawait axios.post(&#034;http:\/\/localhost:3001\/list&#034;, obj);<\/p>\n<p>\/\/ \u914d\u7f6e\u540e&#xff08;\u7b80\u5199&#xff09;<br \/>\nawait axios.get(&#034;\/list&#034;);<br \/>\nawait axios.post(&#034;\/list&#034;, obj);<\/p>\n<h4>3.3 \u5168\u5c40\u914d\u7f6e\u7684\u4f18\u52bf<\/h4>\n<table>\n<tr>\n<p>\u4f18\u52bf<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u51cf\u5c11\u91cd\u590d\u4ee3\u7801\u200b<\/p>\n<\/td>\n<td>\n<p>\u6240\u6709\u8bf7\u6c42\u5171\u4eabbaseURL\u548ctimeout<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u4fbf\u4e8e\u7ef4\u62a4\u200b<\/p>\n<\/td>\n<td>\n<p>\u4fee\u6539API\u5730\u5740\u53ea\u9700\u6539\u4e00\u5904<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7edf\u4e00\u7ba1\u7406\u200b<\/p>\n<\/td>\n<td>\n<p>\u8d85\u65f6\u65f6\u95f4\u3001\u8bf7\u6c42\u5934\u7b49\u5168\u5c40\u751f\u6548<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u56db\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>4.1 \u540c\u6e90\u7b56\u7565<\/h4>\n<p>\u540c\u6e90\u7b56\u7565&#xff08;Same-Origin Policy&#xff09;\u6700\u65e9\u7531Netscape\u516c\u53f8\u63d0\u51fa&#xff0c;\u662f\u6d4f\u89c8\u5668\u7684\u4e00\u79cd\u5b89\u5168\u7b56\u7565\u3002<\/p>\n<table>\n<tr>\n<p>\u6761\u4ef6<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u540c\u6e90\u5b9a\u4e49\u200b<\/p>\n<\/td>\n<td>\n<p>\u534f\u8bae\u3001\u57df\u540d\u3001\u7aef\u53e3\u53f7\u4e09\u8005\u5b8c\u5168\u76f8\u540c\u200b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8de8\u57df\u200b<\/p>\n<\/td>\n<td>\n<p>\u8fdd\u80cc\u540c\u6e90\u7b56\u7565\u5c31\u662f\u8de8\u57df<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u76ee\u7684\u200b<\/p>\n<\/td>\n<td>\n<p>\u4fdd\u62a4\u7528\u6237\u6570\u636e\u5b89\u5168&#xff0c;\u9632\u6b62\u6076\u610f\u7f51\u7ad9\u7a83\u53d6\u6570\u636e<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.2 JSONP\u539f\u7406<\/h4>\n<p>JSONP\u5229\u7528&lt;script&gt;\u6807\u7b7e\u5929\u7136\u652f\u6301\u8de8\u57df\u7684\u7279\u6027\u6765\u5b9e\u73b0\u8de8\u57df\u8bf7\u6c42\u3002<\/p>\n<p>\u5b9e\u73b0\u539f\u7406&#xff1a;<\/p>\n<p>\u5ba2\u6237\u7aef                       \u670d\u52a1\u5668<br \/>\n  \u2502                          \u2502<br \/>\n  \u2502 \u521b\u5efa&lt;script&gt;\u6807\u7b7e         \u2502<br \/>\n  \u2502 \u8bbe\u7f6esrc\u4e3a\u8de8\u57dfURL         \u2502<br \/>\n  \u2502 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba  \u2502<br \/>\n  \u2502                          \u2502<br \/>\n  \u2502      \u8fd4\u56de: handleData({&#034;name&#034;:&#034;jack&#034;})  \u2502<br \/>\n  \u2502 \u25c4\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500  \u2502<br \/>\n  \u2502                          \u2502<br \/>\n  \u2502 \u6267\u884chandleData\u51fd\u6570       \u2502<br \/>\n  \u2502 \u5904\u7406\u8fd4\u56de\u7684\u6570\u636e           \u2502<\/p>\n<p>\u5ba2\u6237\u7aef\u5b9e\u73b0&#xff1a;<\/p>\n<p>\/\/ \u5ba2\u6237\u7aef\u5b9a\u4e49\u5904\u7406\u51fd\u6570<br \/>\nfunction handleData(data) {<br \/>\n    console.log(data);  \/\/ \u5904\u7406\u670d\u52a1\u5668\u8fd4\u56de\u7684\u6570\u636e<br \/>\n}<\/p>\n<p>\/\/ \u521b\u5efascript\u6807\u7b7e\u53d1\u8d77\u8bf7\u6c42<br \/>\nconst script &#061; document.createElement(&#034;script&#034;);<br \/>\nscript.src &#061; &#034;http:\/\/127.0.0.1:8000\/check-username&#034;;<br \/>\ndocument.body.appendChild(script);<\/p>\n<p>JSONP\u7279\u70b9&#xff1a;<\/p>\n<table>\n<tr>\n<p>\u7279\u6027<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u652f\u6301\u65b9\u5f0f<\/p>\n<\/td>\n<td>\n<p>\u53ea\u652f\u6301GET\u8bf7\u6c42<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u517c\u5bb9\u6027<\/p>\n<\/td>\n<td>\n<p>\u517c\u5bb9\u6240\u6709\u6d4f\u89c8\u5668<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5b89\u5168\u6027<\/p>\n<\/td>\n<td>\n<p>\u5bb9\u6613\u53d7\u5230XSS\u653b\u51fb<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u73b0\u4ee3\u66ff\u4ee3<\/p>\n<\/td>\n<td>\n<p>CORS\u662f\u66f4\u597d\u7684\u9009\u62e9<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.3 CORS&#xff08;\u8de8\u57df\u8d44\u6e90\u5171\u4eab&#xff09;<\/h4>\n<p>CORS\u662fW3C\u6807\u51c6&#xff0c;\u901a\u8fc7\u5728\u670d\u52a1\u5668\u7aef\u8bbe\u7f6e\u54cd\u5e94\u5934\u6765\u5b9e\u73b0\u8de8\u57df\u3002<\/p>\n<p>\u5ba2\u6237\u7aef\u5b9e\u73b0&#xff08;\u65e0\u9700\u7279\u6b8a\u5904\u7406&#xff09;&#xff1a;<\/p>\n<p>const xhr &#061; new XMLHttpRequest();<br \/>\nxhr.open(&#034;GET&#034;, &#034;http:\/\/127.0.0.1:8000\/cors-server&#034;);<br \/>\nxhr.send();<\/p>\n<p>xhr.onreadystatechange &#061; function() {<br \/>\n    if (xhr.readyState &#061;&#061;&#061; 4 &amp;&amp; xhr.status &gt;&#061; 200 &amp;&amp; xhr.status &lt; 300) {<br \/>\n        res.innerHTML &#061; xhr.response;<br \/>\n    }<br \/>\n};<\/p>\n<p>\u670d\u52a1\u5668\u7aef\u9700\u8981\u8bbe\u7f6e\u7684\u54cd\u5e94\u5934&#xff1a;<\/p>\n<p>\/\/ Node.js Express\u793a\u4f8b<br \/>\nres.setHeader(&#034;Access-Control-Allow-Origin&#034;, &#034;*&#034;);<\/p>\n<h4>4.4 JSONP vs CORS<\/h4>\n<table>\n<tr>\n<p>\u5bf9\u6bd4\u9879<\/p>\n<p>JSONP<\/p>\n<p>CORS<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u8bf7\u6c42\u65b9\u5f0f\u200b<\/p>\n<\/td>\n<td>\n<p>\u4ec5GET<\/p>\n<\/td>\n<td>\n<p>\u6240\u6709HTTP\u65b9\u6cd5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5b9e\u73b0\u96be\u5ea6\u200b<\/p>\n<\/td>\n<td>\n<p>\u5ba2\u6237\u7aef\u9700\u7279\u6b8a\u5904\u7406<\/p>\n<\/td>\n<td>\n<p>\u5ba2\u6237\u7aef\u65e0\u9700\u5904\u7406<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u6d4f\u89c8\u5668\u517c\u5bb9\u200b<\/p>\n<\/td>\n<td>\n<p>\u5168\u517c\u5bb9<\/p>\n<\/td>\n<td>\n<p>IE10&#043;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5b89\u5168\u6027\u200b<\/p>\n<\/td>\n<td>\n<p>\u8f83\u4f4e&#xff08;XSS\u98ce\u9669&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u8f83\u9ad8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u73b0\u4ee3\u63a8\u8350\u200b<\/p>\n<\/td>\n<td>\n<p>\u274c \u4e0d\u63a8\u8350<\/p>\n<\/td>\n<td>\n<p>\u2705 \u63a8\u8350<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e94\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u5217\u8868\u7ba1\u7406\u7cfb\u7edf<\/h3>\n<h4>5.1 \u7c7b\u7ed3\u6784\u8bbe\u8ba1<\/h4>\n<p>class List {<br \/>\n    \/\/ \u5143\u7d20\u83b7\u53d6<br \/>\n    listOuter &#061; document.querySelector(&#034;.listOuter&#034;);<br \/>\n    inp &#061; document.getElementById(&#034;inp&#034;);<br \/>\n    addBtn &#061; document.getElementById(&#034;add&#034;);<\/p>\n<p>    \/\/ \u6570\u636e\u7ba1\u7406<br \/>\n    mylist &#061; [];<\/p>\n<p>    constructor() {<br \/>\n        this.getData();<br \/>\n        this.addEvent();<br \/>\n    }<\/p>\n<p>    \/\/ \u4e8b\u4ef6\u7ed1\u5b9a<br \/>\n    addEvent() {<br \/>\n        this.addBtn.addEventListener(&#034;click&#034;, this.addFun.bind(this));<br \/>\n    }<\/p>\n<p>    \/\/ \u6570\u636e\u6e32\u67d3<br \/>\n    gender(mylist) {<br \/>\n        let str &#061; &#034;&#034;;<br \/>\n        mylist.forEach((item) &#061;&gt; {<br \/>\n            str &#043;&#061; &#096;&lt;li&gt;${item.name}&lt;a href&#061;&#034;#&#034;&gt;\u5220\u9664&lt;\/a&gt;&lt;\/li&gt;&#096;;<br \/>\n        });<br \/>\n        this.listOuter.innerHTML &#061; str;<br \/>\n    }<\/p>\n<p>    \/\/ \u6570\u636e\u83b7\u53d6<br \/>\n    async getData() {<br \/>\n        try {<br \/>\n            let res &#061; await axios.get(&#034;\/list&#034;);<br \/>\n            this.mylist &#061; res.data;<br \/>\n            this.gender(this.mylist);<br \/>\n        } catch (error) {<br \/>\n            console.log(error);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>5.2 \u529f\u80fd\u5b9e\u73b0\u8981\u70b9<\/h4>\n<table>\n<tr>\n<p>\u8981\u70b9<\/p>\n<p>\u8bf4\u660e<\/p>\n<p>\u5b9e\u73b0\u65b9\u5f0f<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u6570\u636e\u7ed1\u5b9a\u200b<\/p>\n<\/td>\n<td>\n<p>\u4fdd\u6301this\u4e0a\u4e0b\u6587\u6b63\u786e<\/p>\n<\/td>\n<td>\n<p>bind(this)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5f02\u6b65\u5904\u7406\u200b<\/p>\n<\/td>\n<td>\n<p>\u7edf\u4e00\u4f7f\u7528async\/await<\/p>\n<\/td>\n<td>\n<p>try-catch\u5305\u88f9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u9519\u8bef\u5904\u7406\u200b<\/p>\n<\/td>\n<td>\n<p>\u6355\u83b7\u5e76\u6253\u5370\u9519\u8bef<\/p>\n<\/td>\n<td>\n<p>console.log(error)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5b9e\u65f6\u66f4\u65b0\u200b<\/p>\n<\/td>\n<td>\n<p>\u64cd\u4f5c\u540e\u91cd\u65b0\u83b7\u53d6\u6570\u636e<\/p>\n<\/td>\n<td>\n<p>\u8c03\u7528getData()<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>5.3 \u5b8c\u6574CRUD\u64cd\u4f5c<\/h4>\n<p>class List {<br \/>\n    \/\/ &#8230; \u4e0a\u8ff0\u4ee3\u7801 &#8230;<\/p>\n<p>    \/\/ \u65b0\u589e\u6570\u636e<br \/>\n    async addFun() {<br \/>\n        try {<br \/>\n            let obj &#061; {<br \/>\n                id: &#043;new Date(),<br \/>\n                name: this.inp.value,<br \/>\n                age: 2000,<br \/>\n                address: &#034;\u5f85\u5b9a&#034;<br \/>\n            };<br \/>\n            await axios.post(&#034;\/list&#034;, obj);<br \/>\n            this.getData();  \/\/ \u91cd\u65b0\u83b7\u53d6\u6570\u636e<br \/>\n        } catch (error) {<br \/>\n            console.log(error);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u6570\u636e<br \/>\n    async delFun(id) {<br \/>\n        try {<br \/>\n            await axios.delete(&#096;\/list\/${id}&#096;);<br \/>\n            this.getData();  \/\/ \u91cd\u65b0\u83b7\u53d6\u6570\u636e<br \/>\n        } catch (error) {<br \/>\n            console.log(error);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u66f4\u65b0\u6570\u636e&#xff08;\u5b8c\u6574\u66f4\u65b0&#xff09;<br \/>\n    async updateFun(id, newName) {<br \/>\n        try {<br \/>\n            await axios.put(&#096;\/list\/${id}&#096;, {<br \/>\n                name: newName<br \/>\n            });<br \/>\n            this.getData();  \/\/ \u91cd\u65b0\u83b7\u53d6\u6570\u636e<br \/>\n        } catch (error) {<br \/>\n            console.log(error);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u90e8\u5206\u66f4\u65b0<br \/>\n    async patchFun(id, field) {<br \/>\n        try {<br \/>\n            await axios.patch(&#096;\/list\/${id}&#096;, field);<br \/>\n            this.getData();  \/\/ \u91cd\u65b0\u83b7\u53d6\u6570\u636e<br \/>\n        } catch (error) {<br \/>\n            console.log(error);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3>\u516d\u3001\u6ce8\u610f\u4e8b\u9879\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<h4>6.1 \u8bf7\u6c42\u65b9\u6cd5\u9009\u62e9\u6307\u5357<\/h4>\n<table>\n<tr>\n<p>\u64cd\u4f5c<\/p>\n<p>\u8bf7\u6c42\u65b9\u6cd5<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u67e5\u8be2\u6570\u636e\u200b<\/p>\n<\/td>\n<td>\n<p>GET<\/p>\n<\/td>\n<td>\n<p>\u83b7\u53d6\u5217\u8868\u6216\u8be6\u60c5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u65b0\u589e\u6570\u636e\u200b<\/p>\n<\/td>\n<td>\n<p>POST<\/p>\n<\/td>\n<td>\n<p>\u6dfb\u52a0\u65b0\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5b8c\u6574\u66f4\u65b0\u200b<\/p>\n<\/td>\n<td>\n<p>PUT<\/p>\n<\/td>\n<td>\n<p>\u66ff\u6362\u6574\u6761\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u90e8\u5206\u66f4\u65b0\u200b<\/p>\n<\/td>\n<td>\n<p>PATCH<\/p>\n<\/td>\n<td>\n<p>\u4fee\u6539\u90e8\u5206\u5b57\u6bb5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5220\u9664\u6570\u636e\u200b<\/p>\n<\/td>\n<td>\n<p>DELETE<\/p>\n<\/td>\n<td>\n<p>\u5220\u9664\u8bb0\u5f55<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.2 \u8de8\u57df\u89e3\u51b3\u65b9\u6848\u9009\u62e9<\/h4>\n<table>\n<tr>\n<p>\u573a\u666f<\/p>\n<p>\u63a8\u8350\u65b9\u6848<\/p>\n<p>\u539f\u56e0<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u7b80\u5355GET\u8bf7\u6c42\u200b<\/p>\n<\/td>\n<td>\n<p>CORS<\/p>\n<\/td>\n<td>\n<p>\u529f\u80fd\u5b8c\u6574&#xff0c;\u5b89\u5168\u6027\u9ad8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u9700\u8981\u517c\u5bb9IE\u200b<\/p>\n<\/td>\n<td>\n<p>JSONP<\/p>\n<\/td>\n<td>\n<p>\u552f\u4e00\u9009\u62e9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u751f\u4ea7\u73af\u5883\u200b<\/p>\n<\/td>\n<td>\n<p>CORS<\/p>\n<\/td>\n<td>\n<p>\u73b0\u4ee3\u6d4f\u89c8\u5668\u6807\u914d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5f00\u53d1\u8c03\u8bd5\u200b<\/p>\n<\/td>\n<td>\n<p>\u4ee3\u7406\u8f6c\u53d1<\/p>\n<\/td>\n<td>\n<p>\u65e0\u9700\u540e\u7aef\u914d\u5408<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.3 \u9519\u8bef\u5904\u7406\u89c4\u8303<\/h4>\n<p>\/\/ \u2705 \u63a8\u8350\u7684\u9519\u8bef\u5904\u7406\u65b9\u5f0f<br \/>\ntry {<br \/>\n    let res &#061; await axios.get(&#034;\/list&#034;);<br \/>\n    \/\/ \u5904\u7406\u6210\u529f\u6570\u636e<br \/>\n} catch (error) {<br \/>\n    \/\/ \u7edf\u4e00\u9519\u8bef\u5904\u7406<br \/>\n    console.error(&#034;\u8bf7\u6c42\u5931\u8d25:&#034;, error.message);<br \/>\n    alert(&#034;\u6570\u636e\u52a0\u8f7d\u5931\u8d25&#xff0c;\u8bf7\u7a0d\u540e\u91cd\u8bd5&#034;);<br \/>\n}<\/p>\n<h4>6.4 \u6027\u80fd\u4f18\u5316\u5efa\u8bae<\/h4>\n<table>\n<tr>\n<p>\u4f18\u5316\u9879<\/p>\n<p>\u8bf4\u660e<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>\u5168\u5c40\u914d\u7f6e\u200b<\/p>\n<\/td>\n<td>\n<p>\u8bbe\u7f6ebaseURL\u548ctimeout&#xff0c;\u51cf\u5c11\u91cd\u590d\u4ee3\u7801<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5408\u7406\u8d85\u65f6\u200b<\/p>\n<\/td>\n<td>\n<p>\u6839\u636e\u63a5\u53e3\u54cd\u5e94\u901f\u5ea6\u8bbe\u7f6e\u5408\u9002\u7684\u8d85\u65f6\u65f6\u95f4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u9519\u8bef\u63d0\u793a\u200b<\/p>\n<\/td>\n<td>\n<p>\u7ed9\u7528\u6237\u53cb\u597d\u7684\u9519\u8bef\u53cd\u9988<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u6570\u636e\u7f13\u5b58\u200b<\/p>\n<\/td>\n<td>\n<p>\u5bf9\u4e8e\u4e0d\u9891\u7e41\u53d8\u52a8\u7684\u6570\u636e&#xff0c;\u8003\u8651\u672c\u5730\u7f13\u5b58<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u7cfb\u7edf\u68b3\u7406\u4e86AJAX\u7b2c\u4e8c\u90e8\u5206\u7684\u5b8c\u6574\u77e5\u8bc6\u4f53\u7cfb&#xff1a;<\/p>\n<table>\n<tr>\n<p>\u4e3b\u9898<\/p>\n<p>\u6838\u5fc3\u8981\u70b9<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>Axios\u4e94\u79cd\u65b9\u6cd5\u200b<\/p>\n<\/td>\n<td>\n<p>GET\u67e5\u8be2\u3001POST\u65b0\u589e\u3001PUT\u5b8c\u6574\u66f4\u65b0\u3001PATCH\u90e8\u5206\u66f4\u65b0\u3001DELETE\u5220\u9664<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5168\u5c40\u914d\u7f6e\u200b<\/p>\n<\/td>\n<td>\n<p>baseURL\u7edf\u4e00\u7ba1\u7406\u3001timeout\u8d85\u65f6\u63a7\u5236<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u200b<\/p>\n<\/td>\n<td>\n<p>JSONP&#xff08;\u4ec5GET\u3001\u517c\u5bb9\u8001\u6d4f\u89c8\u5668&#xff09;\u3001CORS&#xff08;\u63a8\u8350\u3001\u529f\u80fd\u5b8c\u6574&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u200b<\/p>\n<\/td>\n<td>\n<p>\u9762\u5411\u5bf9\u8c61\u5c01\u88c5\u3001CRUD\u64cd\u4f5c\u3001\u6570\u636e\u5b9e\u65f6\u66f4\u65b0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9&#xff0c;\u4f60\u5c31\u5177\u5907\u4e86\u5b8c\u6574\u7684\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u80fd\u529b&#xff0c;\u80fd\u591f\u72ec\u7acb\u5b8c\u6210\u589e\u5220\u6539\u67e5\u529f\u80fd\u7684\u5f00\u53d1\u3002\u6b22\u8fce\u6301\u7eed\u5173\u6ce8\u672c\u7cfb\u5217\u66f4\u591a\u8fdb\u9636\u5185\u5bb9&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\u672c\u6587\u662fAJAX\u7cfb\u5217\u7684\u7b2c\u4e8c\u7bc7&#xff0c;\u6df1\u5165\u8bb2\u89e3Axios\u7684\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5&#xff08;GET\/POST\/PUT\/PATCH\/DELETE&#xff09;\u3001\u5168\u5c40\u914d\u7f6e\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848&#xff08;JSONP\u4e0eCORS&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218\u6848\u4f8b\u4e32\u8054\u6240\u6709\u77e5\u8bc6\u70b9\u3002\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9&#xff0c;\u4f60\u5c06\u80fd\u591f\u72ec\u7acb\u5b8c\u6210\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u4e00\u3001Axios\u57fa\u7840\u56de\u987e1.1 \u5f15\u5165Axios&lt;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2390],"topic":[],"class_list":["post-101524","post","type-post","status-publish","format-standard","hentry","category-server","tag-okhttp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/101524.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00\u672c\u6587\u662fAJAX\u7cfb\u5217\u7684\u7b2c\u4e8c\u7bc7&#xff0c;\u6df1\u5165\u8bb2\u89e3Axios\u7684\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5&#xff08;GET\/POST\/PUT\/PATCH\/DELETE&#xff09;\u3001\u5168\u5c40\u914d\u7f6e\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848&#xff08;JSONP\u4e0eCORS&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218\u6848\u4f8b\u4e32\u8054\u6240\u6709\u77e5\u8bc6\u70b9\u3002\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9&#xff0c;\u4f60\u5c06\u80fd\u591f\u72ec\u7acb\u5b8c\u6210\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u4e00\u3001Axios\u57fa\u7840\u56de\u987e1.1 \u5f15\u5165Axios&lt;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/101524.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-06T16:35:39+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101524.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/101524.html\",\"name\":\"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-06T16:35:39+00:00\",\"dateModified\":\"2026-09-06T16:35:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/101524.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/101524.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101524.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/101524.html","og_locale":"zh_CN","og_type":"article","og_title":"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00\u672c\u6587\u662fAJAX\u7cfb\u5217\u7684\u7b2c\u4e8c\u7bc7&#xff0c;\u6df1\u5165\u8bb2\u89e3Axios\u7684\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5&#xff08;GET\/POST\/PUT\/PATCH\/DELETE&#xff09;\u3001\u5168\u5c40\u914d\u7f6e\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848&#xff08;JSONP\u4e0eCORS&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218\u6848\u4f8b\u4e32\u8054\u6240\u6709\u77e5\u8bc6\u70b9\u3002\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9&#xff0c;\u4f60\u5c06\u80fd\u591f\u72ec\u7acb\u5b8c\u6210\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u4e00\u3001Axios\u57fa\u7840\u56de\u987e1.1 \u5f15\u5165Axios&lt;","og_url":"https:\/\/www.wsisp.com\/helps\/101524.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-06T16:35:39+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/101524.html","url":"https:\/\/www.wsisp.com\/helps\/101524.html","name":"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-06T16:35:39+00:00","dateModified":"2026-09-06T16:35:39+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/101524.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/101524.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/101524.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"JS AJAX\u5b8c\u5168\u6307\u5357\uff08\u4e8c\uff09\uff1aAxios\u4e94\u79cd\u8bf7\u6c42\u65b9\u6cd5\u3001\u8de8\u57df\u89e3\u51b3\u65b9\u6848\u4e0e\u5217\u8868\u7ba1\u7406\u7cfb\u7edf\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=101524"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101524\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=101524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=101524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=101524"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=101524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}