{"id":1286,"date":"2024-11-10T17:35:29","date_gmt":"2024-11-10T09:35:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1286\/"},"modified":"2024-11-10T17:35:29","modified_gmt":"2024-11-10T09:35:29","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8-javascript-%e4%bb%8e%e5%a4%96%e9%83%a8-url-%e8%8e%b7%e5%8f%96%e6%95%b0%e6%8d%ae%e5%b9%b6%e6%98%be%e7%a4%ba%e5%9c%a8%e7%bd%91%e9%a1%b5%e4%b8%8a%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1286\/","title":{"rendered":"\u5982\u4f55\u5229\u7528 JavaScript \u4ece\u5916\u90e8 URL \u83b7\u53d6\u6570\u636e\u5e76\u663e\u793a\u5728\u7f51\u9875\u4e0a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173035258719180.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5229\u7528 JavaScript \u4ece\u5916\u90e8 URL \u83b7\u53d6\u6570\u636e\u5e76\u663e\u793a\u5728\u7f51\u9875\u4e0a\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5229\u7528 JavaScript \u4ece\u5916\u90e8 URL \u83b7\u53d6\u6570\u636e\u5e76\u663e\u793a\u5728\u7f51\u9875\u4e0a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728\u524d\u7aef\u5229\u7528 javascript \u8bbf\u95ee\u5916\u90e8\u6570\u636e\uff1f<\/strong><\/p>\n<p>\u95ee\u9898\uff1a\u5982\u4f55\u901a\u8fc7 javascript \u4ece externe url \u83b7\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8d4b\u503c\u7ed9 html \u4e2d\u7684\u5143\u7d20\uff1f<\/p>\n<p>\u56de\u7b54\uff1a<\/p>\n<p>\u8bf7\u6c42\u7c7b\u578b\u4e3a document \u7684 url \u65e0\u6cd5\u4f7f\u7528 ajax\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c cdn \u5f15\u5165\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>&lt;script src=\"https:\/\/cdn.bootcdn.net\/ajax\/libs\/jquery\/3.6.4\/jquery.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u83b7\u53d6\u6570\u636e\u5e76\u8d4b\u503c\u5230 html \u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;div class=\"city\"&gt;&lt;\/div&gt;\n&lt;script&gt;\n  $.getJSON(\"http:\/\/ip.tanwan.com\/index.php?action=ipinfo&amp;format=js\", function (data) {\n    console.log(data);\n    $('.city').text(data.countryName);\n  });\n&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u6b64\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4ece\u5916\u90e8 url \u52a0\u8f7d\u6570\u636e\uff0c\u5e76\u52a8\u6001\u66f4\u65b0 html \u5185\u5bb9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5229\u7528 JavaScript \u4ece\u5916\u90e8 URL \u83b7\u53d6\u6570\u636e\u5e76\u663e\u793a\u5728\u7f51\u9875\u4e0a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728\u524d\u7aef\u5229\u7528 javascript \u8bbf\u95ee\u5916\u90e8\u6570\u636e\uff1f \u95ee\u9898\uff1a\u5982\u4f55\u901a\u8fc7 javascript \u4ece externe url \u83b7\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8d4b\u503c\u7ed9 html \u4e2d\u7684\u5143\u7d20\uff1f \u56de\u7b54\uff1a \u8bf7\u6c42\u7c7b\u578b\u4e3a document \u7684 url \u65e0\u6cd5\u4f7f\u7528 ajax\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c cdn \u5f15\u5165\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b &lt;script src=&#8221;https:\/\/cdn.bootcdn.net\/ajax\/libs\/jquery\/3.6.4\/jquery.min.js&#8221;&gt;&lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u83b7\u53d6\u6570\u636e\u5e76\u8d4b\u503c\u5230 html \u7684\u4ee3\u7801\u5982\u4e0b\uff1a &lt;div class=&#8221;city&#8221;&gt;&lt;\/div&gt; &lt;script&gt; $.getJSON(&#8220;http:\/\/ip.tanwan.com\/index.php?action=ipinfo&amp;format=js&#8221;, function (data) { console.log(data); $(&#8216;.city&#8217;).text(data.countryName); }); &lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u6b64\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4ece\u5916\u90e8 url \u52a0\u8f7d\u6570\u636e\uff0c\u5e76\u52a8\u6001\u66f4\u65b0 html \u5185\u5bb9\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5229\u7528 JavaScript \u4ece\u5916\u90e8 URL \u83b7\u53d6\u6570\u636e\u5e76\u663e\u793a\u5728\u7f51\u9875\u4e0a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1286","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1286"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1286\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}