{"id":49004,"date":"2024-12-02T12:17:22","date_gmt":"2024-12-02T04:17:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49004\/"},"modified":"2024-12-02T12:17:22","modified_gmt":"2024-12-02T04:17:22","slug":"javascript-post-%e6%97%a0%e6%b3%95%e6%89%a7%e8%a1%8c%ef%bc%9a%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5%e5%92%8c%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49004\/","title":{"rendered":"JavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>JavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300aJavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241106\/1730871407672b006faa326.jpg\" class=\"aligncenter\" title=\"JavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"JavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u89e3\u51b3 javascript $.post \u65e0\u6cd5\u6267\u884c\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u5411 php \u9875\u9762\u4f20\u8f93\u503c\u7684 javascript \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4e86 $.post \u65b9\u6cd5\uff0c\u4f46\u5374\u6ca1\u6709\u6267\u884c\u3002\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u7531\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\uff1a<\/p>\n<p>\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 $.post()\uff0c\u8fd9\u662f\u4e00\u4e2a jquery \u51fd\u6570\uff0c\u9700\u8981\u5305\u542b jquery \u5e93\u624d\u80fd\u4f7f\u7528\u3002\u8bf7\u786e\u4fdd\u5df2\u5c06 jquery \u5e93\u5305\u542b\u5728\u60a8\u7684 html \u9875\u9762\u4e2d\u3002<\/p>\n<p>\u4ee3\u7801\u4e2d\u7f3a\u5c11\u5bf9\u6309\u94ae\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u3002\u867d\u7136\u63d0\u4f9b\u4e86 onclick=&#8221;save()&#8221;\uff0c\u4f46\u8fd8\u9700\u8981\u6dfb\u52a0 event \u53c2\u6570\u6765\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\u3002\u4e8b\u4ef6\u76d1\u542c\u5668\u5e94\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;button class=\"button_1\" id=\"save_btn\" ontouchstart=\"\" onclick=\"save(event)\"&gt;\u62a5\u540d&lt;\/button&gt;<\/pre>\n<p>\u786e\u4fdd php \u6587\u4ef6 sa1.php \u5b58\u5728\u4e14\u5177\u6709\u6b63\u786e\u7684\u6587\u4ef6\u6743\u9650\uff08\u4f8b\u5982\uff0c755\uff09\u3002<\/p>\n<p>\u68c0\u67e5\u662f\u5426\u5728 php \u6587\u4ef6\u4e2d\u6b63\u786e\u5730\u6253\u5370\u4e86\u6587\u672c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>printf(\"4353\");<\/pre>\n<p>\u5e94\u5c06\u6587\u672c\u8f93\u51fa\u5230\u54cd\u5e94\u4e2d\u3002<\/p>\n<p><strong>\u66f4\u65b0\u540e\u7684\u4ee3\u7801\uff1a<\/strong><\/p>\n<p><strong>html\uff1a<\/strong><\/p>\n<pre>&lt;button class=\"button_1\" id=\"save_btn\" ontouchstart=\"\" onclick=\"save(event)\"&gt;\u62a5\u540d&lt;\/button&gt;\n\n&lt;script type=\"text\/javascript\"&gt;\nfunction save(event) {\n  event.preventdefault();\n  \/\/ ... \u5176\u4ed6\u4ee3\u7801\n}\n&lt;\/script&gt;<\/pre>\n<p><strong>php\uff08sa1.php\uff09\uff1a<\/strong><\/p>\n<pre>&lt;?php\n  file_put_contents(\"log.html\",date('Y-m-d H:i:s ').$_POST[\"id\"].\"&amp;lt;br&amp;gt;\",FILE_APPEND);\n  echo \"4353\";\n?&gt;<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300aJavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f \u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300aJavaScript $.post \u65e0\u6cd5\u6267\u884c\uff1a\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~ \u89e3\u51b3 javascript $.post \u65e0\u6cd5\u6267\u884c\u95ee\u9898 \u5728\u5411 php \u9875\u9762\u4f20\u8f93\u503c\u7684 javascript \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4e86 $.post \u65b9\u6cd5\uff0c\u4f46\u5374\u6ca1\u6709\u6267\u884c\u3002\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u7531\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\uff1a \u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 $.post()\uff0c\u8fd9\u662f\u4e00\u4e2a jquery \u51fd\u6570\uff0c\u9700\u8981\u5305\u542b jquery \u5e93\u624d\u80fd\u4f7f\u7528\u3002\u8bf7\u786e\u4fdd\u5df2\u5c06 jquery \u5e93\u5305\u542b\u5728\u60a8\u7684 html \u9875\u9762\u4e2d\u3002 \u4ee3\u7801\u4e2d\u7f3a\u5c11\u5bf9\u6309\u94ae\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u3002\u867d\u7136\u63d0\u4f9b\u4e86 onclick=&#8221;save()&#8221;\uff0c\u4f46\u8fd8\u9700\u8981\u6dfb\u52a0 event \u53c2\u6570\u6765\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\u3002\u4e8b\u4ef6\u76d1\u542c\u5668\u5e94\u5982\u4e0b\u6240\u793a\uff1a &lt;button class=&#8221;button_1&#8243; id=&#8221;save_btn&#8221; ontouchstart=&#8221;&#8221; onclick=&#8221;save(event)&#8221;&gt;\u62a5\u540d&lt;\/button&gt; \u786e\u4fdd php \u6587\u4ef6 sa1.php \u5b58\u5728\u4e14\u5177\u6709\u6b63\u786e\u7684\u6587\u4ef6\u6743\u9650\uff08\u4f8b\u5982\uff0c755\uff09\u3002 \u68c0\u67e5\u662f\u5426\u5728 php \u6587\u4ef6\u4e2d\u6b63\u786e\u5730\u6253\u5370\u4e86\u6587\u672c\u3002\u4f8b\u5982\uff1a printf(&#8220;4353&#8243;); \u5e94\u5c06\u6587\u672c\u8f93\u51fa\u5230\u54cd\u5e94\u4e2d\u3002 \u66f4\u65b0\u540e\u7684\u4ee3\u7801\uff1a html\uff1a &lt;button class=&#8221;button_1&#8243; id=&#8221;save_btn&#8221; ontouchstart=&#8221;&#8221; onclick=&#8221;save(event)&#8221;&gt;\u62a5\u540d&lt;\/button&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; [&hellip;]<\/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-49004","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49004","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=49004"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49004\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}