{"id":2079,"date":"2024-11-10T10:40:08","date_gmt":"2024-11-10T02:40:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2079\/"},"modified":"2024-11-10T10:40:08","modified_gmt":"2024-11-10T02:40:08","slug":"%e4%bd%bf%e7%94%a8jquery-ajax%e8%bf%9b%e8%a1%8c%e7%b3%bb%e7%bb%9f%e7%99%bb%e5%bd%95%e6%97%b6%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%90%8c%e6%ad%a5%e6%89%a7%e8%a1%8c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2079\/","title":{"rendered":"\u4f7f\u7528jQuery Ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\u5982\u4f55\u5b9e\u73b0\u540c\u6b65\u6267\u884c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173063810129704.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528jQuery Ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\u5982\u4f55\u5b9e\u73b0\u540c\u6b65\u6267\u884c\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528jQuery Ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\u5982\u4f55\u5b9e\u73b0\u540c\u6b65\u6267\u884c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>ajax\u7cfb\u7edf\u767b\u5f55\u7684\u540c\u6b65\u6267\u884c<\/strong><\/p>\n<p>\u5728\u4f7f\u7528jquery ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\uff0c\u6709\u65f6\u9700\u8981\u5c06ajax\u6267\u884c\u65b9\u5f0f\u6539\u4e3a\u540c\u6b65\uff0c\u5373async: false\u3002\u539f\u56e0\u662f\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cajax\u662f\u5f02\u6b65\u6267\u884c\u7684\uff0c\u5728\u540e\u53f0\u5224\u65ad\u767b\u5f55\u4fe1\u606f\u4e4b\u524d\uff0c\u53ef\u80fd\u4f1a\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u4fee\u6539\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>$.ajax({\n  url: '@Url.Action(\"Login\")',\n  data: {\n    name: username,\n    pwd: password\n  },\n  dataType: \"json\",\n  type: \"POST\",\n  traditional: true,\n  async: false\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u5728ajax\u914d\u7f6e\u4e2d\u6dfb\u52a0async: false\uff0c\u5c06ajax\u6267\u884c\u65b9\u5f0f\u6539\u4e3a\u540c\u6b65\u3002\u6b64\u65f6\uff0c\u540e\u53f0\u4f1a\u5148\u5224\u65ad\u767b\u5f55\u4fe1\u606f\uff0c\u518d\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u3002<\/p>\n<p>\u8be5\u5bf9\u8c61\u5c06\u5728ajax\u56de\u8c03success\u4e2d\u8fd4\u56de\uff0c\u53ef\u4ee5\u7528\u6765\u5224\u65ad\u767b\u5f55\u7ed3\u679c\u548c\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528jQuery Ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\u5982\u4f55\u5b9e\u73b0\u540c\u6b65\u6267\u884c\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>ajax\u7cfb\u7edf\u767b\u5f55\u7684\u540c\u6b65\u6267\u884c \u5728\u4f7f\u7528jquery ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\uff0c\u6709\u65f6\u9700\u8981\u5c06ajax\u6267\u884c\u65b9\u5f0f\u6539\u4e3a\u540c\u6b65\uff0c\u5373async: false\u3002\u539f\u56e0\u662f\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cajax\u662f\u5f02\u6b65\u6267\u884c\u7684\uff0c\u5728\u540e\u53f0\u5224\u65ad\u767b\u5f55\u4fe1\u606f\u4e4b\u524d\uff0c\u53ef\u80fd\u4f1a\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u3002 \u4fee\u6539\u4ee3\u7801\uff1a $.ajax({ url: &#8216;@Url.Action(&#8220;Login&#8221;)&#8217;, data: { name: username, pwd: password }, dataType: &#8220;json&#8221;, type: &#8220;POST&#8221;, traditional: true, async: false }); \u767b\u5f55\u540e\u590d\u5236 \u89e3\u51b3\u65b9\u6848\uff1a \u5728ajax\u914d\u7f6e\u4e2d\u6dfb\u52a0async: false\uff0c\u5c06ajax\u6267\u884c\u65b9\u5f0f\u6539\u4e3a\u540c\u6b65\u3002\u6b64\u65f6\uff0c\u540e\u53f0\u4f1a\u5148\u5224\u65ad\u767b\u5f55\u4fe1\u606f\uff0c\u518d\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u3002 \u8be5\u5bf9\u8c61\u5c06\u5728ajax\u56de\u8c03success\u4e2d\u8fd4\u56de\uff0c\u53ef\u4ee5\u7528\u6765\u5224\u65ad\u767b\u5f55\u7ed3\u679c\u548c\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002 \u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528jQuery Ajax\u8fdb\u884c\u7cfb\u7edf\u767b\u5f55\u65f6\u5982\u4f55\u5b9e\u73b0\u540c\u6b65\u6267\u884c\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-2079","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2079","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=2079"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2079\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}