{"id":59179,"date":"2025-04-23T15:38:54","date_gmt":"2025-04-23T07:38:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/59179\/"},"modified":"2025-04-23T15:38:54","modified_gmt":"2025-04-23T07:38:54","slug":"%e5%bd%bb%e5%ba%95%e6%94%b9%e6%ad%a3ecshop%e4%b8%8d%e5%85%bc%e5%ae%b9jquery%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/59179\/","title":{"rendered":"\u5f7b\u5e95\u6539\u6b63ecshop\u4e0d\u517c\u5bb9jquery\u7684\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<p>\u539f\u56e0\u5206\u6790\uff1a<br \/> \u5728transport.js\u6587\u4ef6\u4e2d\uff0c\u5927\u6982 580\u884c\u5230590\u884c\u4e4b\u95f4\uff0c\u8fd9\u4e2a\u53e5\u7528\u4e8e\u683c\u5f0f\u5316json,\u4ed6\u91cd\u5199\u4e86object\u7684\u7ed3\u6784,\u5bfc\u81f4\u4e8ejs\u6846\u67b6\u51b2\u7a81\u3002\u51b2\u7a81\u7684\u539f\u56e0\u662fjquery\u7ed9\u4e00\u4e2aobject\u589e\u52a0\u4e86\u5f88\u591a\u5143\u7d20\uff0c\u90a3\u4e48\u5728Object.prototype.toJSONString = function () \u8fd9\u4e2a\u51fd\u6570\u4e2d for (k in this) \u8bed\u53e5\u4e2d\u8fdb\u884c\u4e86\u65e0\u6570\u6b21\u7684\u5faa\u73af\uff0c\u5bfc\u81f4\u7f51\u9875\u5f88\u5361\uff0c\u5e76\u4e14\u5728IE\u4e2d\u4f1a\u62a5\u9519\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<br \/> \u6839\u672c\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u4e0d\u7528transport.js\u4e2d\u7684json\u529f\u80fd\uff0c\u90a3\u4e48\u5c31\u8981\u6709\u4e00\u4e2a\u76f8\u540c\u7684\u529f\u80fd\u6765\u4ee3\u66ff\u5b83\uff0c\u8fd9\u91cc\u6211\u9009\u7528jquery-json1.3.js\u3002\u9996\u5148\u8981\u628atransport.js\u4e2d\u7684json\u529f\u80fd\u5220\u9664\u3002\u7531\u4e8e\u5b9e\u73b0json\u529f\u80fd\u7684\u51fd\u6570\u6709\u533a\u522b\uff0c\u6240\u4ee5\u8981\u9ebb\u70e6\u6539\u6389\u539fecshop\u4e2d\u5404\u4e2a\u5730\u65b9\u7528\u5230\u7684toJSONString()\u51fd\u6570\u3002<\/p>\n<p>\u89e3\u51b3\u6b65\u9aa4\uff1a<br \/> 1. \u4e0b\u8f7d\u9644\u4ef6\u4e2d\u7684js\u9644\u4ef6\uff0c\u5e76\u66ff\u6362\u6389\u539f\u6587\u4ef6\u3002\uff08\u4e3b\u8981\u53bb\u6389\u4e86transport.js\u7684json\u529f\u80fd\u5e76\u65b0\u589e\u65b0\u7684json\u529f\u80fd\uff09<br \/> 2. page_header.lbi \u4e2d\u6dfb\u52a0 {insert_scripts files=&#8217;jquery.js,jquery.json-1.3.js&#8217;}<br \/> 3. \u5728\u6240\u6709\u7684JS\u4e2d\u3002<br \/> \u66ff\u6362 *.toJSONString() \u4e3a $.toJSON(*)<br \/> \u66ff\u6362 *.parseJSON() \u4e3a $.evalJSON(*)<br \/> \u66ff\u6362(\u4e0d\u662f\u53bb\u6389)\u9875\u9762\u6240\u6709\u7684$(){}\u51fd\u6570\uff0c\u9632\u6b62jquery\u4e0d\u751f\u6548(\u89e3\u91ca\uff1a\u8fd9\u4e00\u6b65\u662f\u8981\u66ff\u6362\u6389\u539fecshop\u91cc\u7684$(){}\u8fd9\u4e2a\u51fd\u6570\uff0c\u56e0\u4e3a\u5b83\u4e0ejquery\u662f\u51b2\u7a81\u7684\uff0c\u89e3\u51b3\u7684\u529e\u6cd5\u5f88\u591a\uff0c\u53ef\u4ee5\u7528\u5176\u4ed6\u51fd\u6570\u4ee3\u66ff\uff0c\u6bd4\u5982getId(){}\u7b49\u7b49\uff0c\u4e5f\u53ef\u4ee5\u7528jquery\u672c\u8eab\u6765\u89e3\u51b3\uff0c\u5728\u6b64\uff0c\u6211\u5c31\u4e0d\u5177\u4f53\u505a\u4f8b\u5b50\u4e86\uff0c\u7531\u4e8e\u6700\u8fd1\u6bd4\u8f83\u5fd9\uff0c\u597d\u591a\u5929\u6ca1\u7814\u7a76ecshop\u4e86\u3002^_^ .\u8fd8\u6709\u4e00\u4e2a\u89e3\u51b3\u529e\u6cd5\uff0c\u5927\u5bb6\u81ea\u884c\u7814\u7a76\u5427\uff1a<br \/> jQuery.noConflict()<br \/> \u8fd0\u884c\u8fd9\u4e2a\u51fd\u6570\u5c06\u53d8\u91cf$\u7684\u63a7\u5236\u6743\u8ba9\u6e21\u7ed9\u7b2c\u4e00\u4e2a\u5b9e\u73b0\u5b83\u7684\u90a3\u4e2a\u5e93\u3002<br \/> \u8fd9\u6709\u52a9\u4e8e\u786e\u4fddjQuery\u4e0d\u4f1a\u4e0e\u5176\u4ed6\u5e93\u7684$\u5bf9\u8c61\u53d1\u751f\u51b2\u7a81\u3002<br \/> \u5728\u8fd0\u884c\u8fd9\u4e2a\u51fd\u6570\u540e\uff0c\u5c31\u53ea\u80fd\u4f7f\u7528jQuery\u53d8\u91cf\u8bbf\u95eejQuery\u5bf9\u8c61\u3002\u4f8b\u5982\uff0c\u5728\u8981\u7528\u5230$(&#8220;div p&#8221;)\u7684\u5730\u65b9\uff0c\u5c31\u5fc5\u987b\u6362\u6210jQuery(&#8220;div p&#8221;)\u3002<br \/> \u6ce8\u610f:\u8fd9\u4e2a\u51fd\u6570\u5fc5\u987b\u5728\u4f60\u5bfc\u5165jQuery\u6587\u4ef6\u4e4b\u540e\uff0c\u5e76\u4e14\u5728\u5bfc\u5165\u53e6\u4e00\u4e2a\u5bfc\u81f4\u51b2\u7a81\u7684\u5e93\u4e4b\u524d\u4f7f\u7528\u3002\u5f53\u7136\u4e5f\u5e94\u5f53\u5728\u5176\u4ed6\u51b2\u7a81\u7684\u5e93\u88ab\u4f7f\u7528\u4e4b\u524d\uff0c\u9664\u975ejQuery\u662f\u6700\u540e\u4e00\u4e2a\u5bfc\u5165\u7684\u3002<\/p>\n<p>)<\/p>\n<p>\u6ce8\u610f\uff1a\u53ef\u80fd\u8981\u66ff\u6362\u6389\u5f88\u591a\u5730\u65b9\uff0c\u8bf7\u5927\u5bb6\u4e0d\u8981\u6015\u9ebb\u70e6<\/p>\n<p> \u89e3\u51b3\u8303\u4f8b\uff1a<br \/> 1.\u5728\u5546\u54c1\u6d4f\u89c8\u9875\uff0c\u7528\u6237\u8bc4\u8bba\u8fd9\u91cc\uff1a<br \/> Ajax.call(&#8216;comment.php&#8217;, &#8216;cmt=&#8217; + cmt.toJSONString(), commentResponse, &#8216;POST&#8217;, &#8216;JSON&#8217;);<br \/> \u66ff\u6362\u4e3a<br \/> Ajax.call(&#8216;comment.php&#8217;, &#8216;cmt=&#8217; + $.toJSON(cmt), commentResponse, &#8216;POST&#8217;, &#8216;JSON&#8217;);<\/p>\n<p>2.index.js \u91cc<br \/> var res = result.parseJSON();<br \/> \u66ff\u6362\u4e3a<br \/> var res = $.evalJSON(result);<\/p>\n<p>\u4ee5\u4e0b\u662f\u4fee\u6539\u8fc7\u7684\u6587\u4ef6\uff1a<br \/> js\\compare.js<\/p>\n<p>\\js\\common.js<\/p>\n<p>\\js\\transport.js<br \/> \\themes\\modify\\library\\member_info.lbi<\/p>\n<p>\\admin\\js\\selectzone.js<br \/> \\admin\\templates\\topic_edit.htm<\/p>\n<p>\\admin\\templates\\menu.htm<br \/> \\admin\\templates\\topic_edit.htm<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u56e0\u5206\u6790\uff1a \u5728transport.js\u6587\u4ef6\u4e2d\uff0c\u5927\u6982 580\u884c\u5230590\u884c\u4e4b\u95f4\uff0c\u8fd9\u4e2a\u53e5\u7528\u4e8e\u683c\u5f0f\u5316json,\u4ed6\u91cd\u5199\u4e86object\u7684\u7ed3\u6784,\u5bfc\u81f4\u4e8ejs\u6846\u67b6\u51b2\u7a81\u3002\u51b2\u7a81\u7684\u539f\u56e0\u662fjquery\u7ed9\u4e00\u4e2aobject\u589e\u52a0\u4e86\u5f88\u591a\u5143\u7d20\uff0c\u90a3\u4e48\u5728Object.prototype.toJSONString = function () \u8fd9\u4e2a\u51fd\u6570\u4e2d for (k in this) \u8bed\u53e5\u4e2d\u8fdb\u884c\u4e86\u65e0\u6570\u6b21\u7684\u5faa\u73af\uff0c\u5bfc\u81f4\u7f51\u9875\u5f88\u5361\uff0c\u5e76\u4e14\u5728IE\u4e2d\u4f1a\u62a5\u9519\u3002 &nbsp; \u89e3\u51b3\u65b9\u6848\uff1a \u6839\u672c\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u4e0d\u7528transport.js\u4e2d\u7684json\u529f\u80fd\uff0c\u90a3\u4e48\u5c31\u8981\u6709\u4e00\u4e2a\u76f8\u540c\u7684\u529f\u80fd\u6765\u4ee3\u66ff\u5b83\uff0c\u8fd9\u91cc\u6211\u9009\u7528jquery-json1.3.js\u3002\u9996\u5148\u8981\u628atransport.js\u4e2d\u7684json\u529f\u80fd\u5220\u9664\u3002\u7531\u4e8e\u5b9e\u73b0json\u529f\u80fd\u7684\u51fd\u6570\u6709\u533a\u522b\uff0c\u6240\u4ee5\u8981\u9ebb\u70e6\u6539\u6389\u539fecshop\u4e2d\u5404\u4e2a\u5730\u65b9\u7528\u5230\u7684toJSONString()\u51fd\u6570\u3002 \u89e3\u51b3\u6b65\u9aa4\uff1a 1. \u4e0b\u8f7d\u9644\u4ef6\u4e2d\u7684js\u9644\u4ef6\uff0c\u5e76\u66ff\u6362\u6389\u539f\u6587\u4ef6\u3002\uff08\u4e3b\u8981\u53bb\u6389\u4e86transport.js\u7684json\u529f\u80fd\u5e76\u65b0\u589e\u65b0\u7684json\u529f\u80fd\uff09 2. page_header.lbi \u4e2d\u6dfb\u52a0 {insert_scripts files=&#8217;jquery.js,jquery.json-1.3.js&#8217;} 3. \u5728\u6240\u6709\u7684JS\u4e2d\u3002 \u66ff\u6362 *.toJSONString() \u4e3a $.toJSON(*) \u66ff\u6362 *.parseJSON() \u4e3a $.evalJSON(*) \u66ff\u6362(\u4e0d\u662f\u53bb\u6389)\u9875\u9762\u6240\u6709\u7684$(){}\u51fd\u6570\uff0c\u9632\u6b62jquery\u4e0d\u751f\u6548(\u89e3\u91ca\uff1a\u8fd9\u4e00\u6b65\u662f\u8981\u66ff\u6362\u6389\u539fecshop\u91cc\u7684$(){}\u8fd9\u4e2a\u51fd\u6570\uff0c\u56e0\u4e3a\u5b83\u4e0ejquery\u662f\u51b2\u7a81\u7684\uff0c\u89e3\u51b3\u7684\u529e\u6cd5\u5f88\u591a\uff0c\u53ef\u4ee5\u7528\u5176\u4ed6\u51fd\u6570\u4ee3\u66ff\uff0c\u6bd4\u5982getId(){}\u7b49\u7b49\uff0c\u4e5f\u53ef\u4ee5\u7528jquery\u672c\u8eab\u6765\u89e3\u51b3\uff0c\u5728\u6b64\uff0c\u6211\u5c31\u4e0d\u5177\u4f53\u505a\u4f8b\u5b50\u4e86\uff0c\u7531\u4e8e\u6700\u8fd1\u6bd4\u8f83\u5fd9\uff0c\u597d\u591a\u5929\u6ca1\u7814\u7a76ecshop\u4e86\u3002^_^ .\u8fd8\u6709\u4e00\u4e2a\u89e3\u51b3\u529e\u6cd5\uff0c\u5927\u5bb6\u81ea\u884c\u7814\u7a76\u5427\uff1a jQuery.noConflict() \u8fd0\u884c\u8fd9\u4e2a\u51fd\u6570\u5c06\u53d8\u91cf$\u7684\u63a7\u5236\u6743\u8ba9\u6e21\u7ed9\u7b2c\u4e00\u4e2a\u5b9e\u73b0\u5b83\u7684\u90a3\u4e2a\u5e93\u3002 \u8fd9\u6709\u52a9\u4e8e\u786e\u4fddjQuery\u4e0d\u4f1a\u4e0e\u5176\u4ed6\u5e93\u7684$\u5bf9\u8c61\u53d1\u751f\u51b2\u7a81\u3002 \u5728\u8fd0\u884c\u8fd9\u4e2a\u51fd\u6570\u540e\uff0c\u5c31\u53ea\u80fd\u4f7f\u7528jQuery\u53d8\u91cf\u8bbf\u95eejQuery\u5bf9\u8c61\u3002\u4f8b\u5982\uff0c\u5728\u8981\u7528\u5230$(&#8220;div p&#8221;)\u7684\u5730\u65b9\uff0c\u5c31\u5fc5\u987b\u6362\u6210jQuery(&#8220;div p&#8221;)\u3002 \u6ce8\u610f:\u8fd9\u4e2a\u51fd\u6570\u5fc5\u987b\u5728\u4f60\u5bfc\u5165jQuery\u6587\u4ef6\u4e4b\u540e\uff0c\u5e76\u4e14\u5728\u5bfc\u5165\u53e6\u4e00\u4e2a\u5bfc\u81f4\u51b2\u7a81\u7684\u5e93\u4e4b\u524d\u4f7f\u7528\u3002\u5f53\u7136\u4e5f\u5e94\u5f53\u5728\u5176\u4ed6\u51b2\u7a81\u7684\u5e93\u88ab\u4f7f\u7528\u4e4b\u524d\uff0c\u9664\u975ejQuery\u662f\u6700\u540e\u4e00\u4e2a\u5bfc\u5165\u7684\u3002 ) \u6ce8\u610f\uff1a\u53ef\u80fd\u8981\u66ff\u6362\u6389\u5f88\u591a\u5730\u65b9\uff0c\u8bf7\u5927\u5bb6\u4e0d\u8981\u6015\u9ebb\u70e6 \u89e3\u51b3\u8303\u4f8b\uff1a 1.\u5728\u5546\u54c1\u6d4f\u89c8\u9875\uff0c\u7528\u6237\u8bc4\u8bba\u8fd9\u91cc\uff1a Ajax.call(&#8216;comment.php&#8217;, &#8216;cmt=&#8217; + cmt.toJSONString(), commentResponse, &#8216;POST&#8217;, &#8216;JSON&#8217;); \u66ff\u6362\u4e3a Ajax.call(&#8216;comment.php&#8217;, [&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-59179","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59179","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=59179"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59179\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=59179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=59179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=59179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}