{"id":2186,"date":"2024-11-10T12:11:40","date_gmt":"2024-11-10T04:11:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2186\/"},"modified":"2024-11-10T12:11:40","modified_gmt":"2024-11-10T04:11:40","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-ajax-%e5%88%b7%e6%96%b0-jsp-%e9%a1%b5%e9%9d%a2%e5%b9%b6%e9%81%8d%e5%8e%86%e4%b8%8b%e6%8b%89%e6%a1%86%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2186\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Ajax \u5237\u65b0 JSP \u9875\u9762\u5e76\u904d\u5386\u4e0b\u62c9\u6846\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173068364238034.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 Ajax \u5237\u65b0 JSP \u9875\u9762\u5e76\u904d\u5386\u4e0b\u62c9\u6846\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 Ajax \u5237\u65b0 JSP \u9875\u9762\u5e76\u904d\u5386\u4e0b\u62c9\u6846\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>ajax \u5237\u65b0 jsp \u5e76\u904d\u5386\u4e0b\u62c9\u6846<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 ajax \u4ece\u670d\u52a1\u5668\u83b7\u53d6\u6570\u636e\u65f6\uff0c\u9047\u5230\u9700\u8981\u5c06\u83b7\u53d6\u7684\u96c6\u5408\u6570\u636e\u904d\u5386\u5230\u9875\u9762\u53e6\u4e00\u4e2a\u4e0b\u62c9\u6846\u4e2d\u3002\u8be5\u600e\u4e48\u505a\u5462\uff1f<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u6f14\u793a\u4e86\u5982\u4f55\u83b7\u53d6 ajax \u54cd\u5e94\u6570\u636e\u5e76\u904d\u5386\u5230\u4e0b\u62c9\u6846\u4e2d\uff1a<\/p>\n<pre>$.ajax({\n  type: \"POST\",\n  dataType: \"json\",\n  async: false,\n  url: ctp + \"\/pbgx\/ClglClsplr\/ajaxcarListPage.do\",\n  data: {\n    \"cLLB\": cllb,\n    \"cLXH\": clxh,\n    \"cPMC\": cpmc\n  },\n  success: function(data) {\n    \/\/ \u6e05\u7a7a\u4e0b\u62c9\u6846\u9009\u9879\n    $(\"#other_dropdown\").empty();\n    \n    \/\/ \u904d\u5386\u83b7\u53d6\u7684\u96c6\u5408\u6570\u636e\n    $.each(data, function(index, item) {\n      \/\/ \u521b\u5efa\u4e0b\u62c9\u6846\u9009\u9879\n      var option = $(\"&lt;option&gt;\").val(item.id).text(item.name);\n      \n      \/\/ \u6dfb\u52a0\u9009\u9879\u5230\u4e0b\u62c9\u6846\n      $(\"#other_dropdown\").append(option);\n    });\n  }\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u6210\u529f\u83b7\u53d6 ajax \u54cd\u5e94\u6570\u636e\u540e\uff0c\u9996\u5148\u9700\u8981\u6e05\u7a7a\u76ee\u6807\u4e0b\u62c9\u6846\u4e2d\u7684\u73b0\u6709\u9009\u9879\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 jquery \u7684 each \u65b9\u6cd5\u904d\u5386\u96c6\u5408\u6570\u636e\uff0c\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u9009\u9879\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u4e0b\u62c9\u6846\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 Ajax \u5237\u65b0 JSP \u9875\u9762\u5e76\u904d\u5386\u4e0b\u62c9\u6846\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 \u5237\u65b0 jsp \u5e76\u904d\u5386\u4e0b\u62c9\u6846 \u5728\u4f7f\u7528 ajax \u4ece\u670d\u52a1\u5668\u83b7\u53d6\u6570\u636e\u65f6\uff0c\u9047\u5230\u9700\u8981\u5c06\u83b7\u53d6\u7684\u96c6\u5408\u6570\u636e\u904d\u5386\u5230\u9875\u9762\u53e6\u4e00\u4e2a\u4e0b\u62c9\u6846\u4e2d\u3002\u8be5\u600e\u4e48\u505a\u5462\uff1f \u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u6f14\u793a\u4e86\u5982\u4f55\u83b7\u53d6 ajax \u54cd\u5e94\u6570\u636e\u5e76\u904d\u5386\u5230\u4e0b\u62c9\u6846\u4e2d\uff1a $.ajax({ type: &#8220;POST&#8221;, dataType: &#8220;json&#8221;, async: false, url: ctp + &#8220;\/pbgx\/ClglClsplr\/ajaxcarListPage.do&#8221;, data: { &#8220;cLLB&#8221;: cllb, &#8220;cLXH&#8221;: clxh, &#8220;cPMC&#8221;: cpmc }, success: function(data) { \/\/ \u6e05\u7a7a\u4e0b\u62c9\u6846\u9009\u9879 $(&#8220;#other_dropdown&#8221;).empty(); \/\/ \u904d\u5386\u83b7\u53d6\u7684\u96c6\u5408\u6570\u636e $.each(data, function(index, item) { \/\/ \u521b\u5efa\u4e0b\u62c9\u6846\u9009\u9879 var option = $(&#8220;&lt;option&gt;&#8221;).val(item.id).text(item.name); \/\/ \u6dfb\u52a0\u9009\u9879\u5230\u4e0b\u62c9\u6846 $(&#8220;#other_dropdown&#8221;).append(option); }); } }); \u767b\u5f55\u540e\u590d\u5236 [&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-2186","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2186","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=2186"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2186\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}