{"id":61230,"date":"2020-04-09T17:13:53","date_gmt":"2020-04-09T09:13:53","guid":{"rendered":"http:\/\/4563.org\/?p=61230"},"modified":"2020-04-09T17:13:53","modified_gmt":"2020-04-09T09:13:53","slug":"js%e6%8a%98%e8%85%be%e5%a4%b4%e8%a6%81%e7%82%b8%e4%ba%86","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=61230","title":{"rendered":"js\u6298\u817e\u5934\u8981\u70b8\u4e86"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>\u65b0\u7f51\u7edc<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:29:06\t<\/p>\n<h3>js\u6298\u817e\u5934\u8981\u70b8\u4e86<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 \u65b0\u7f51\u7edc \u4e8e 2020-3-24 17:38 \u7f16\u8f91 <\/p>\n<p> for (i = 0; i &lt; $(&quot;.newBarcode&quot;).length; i++) { <br \/>  &nbsp; &nbsp; var bc = $(&quot;.newBarcode&quot;).value;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; var ii = $(&quot;input.newBarcode&quot;).id.replace(\/[^0-9]\/ig,&quot;&quot;);<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; var regString = \/+\/;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; if (!regString.test(bc)) {<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.getJSON(&quot;http:\/\/192.168.0.240\/location.php?barcode=&quot; + bc,function(data){<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!data.location) {<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(ii);<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($(&quot;#prodInfoName&quot; + ii).style.length &lt; 2) {<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(&quot;#prodInfoName&quot; + ii).css(&#8216;color&#8217;,&#8217;red&#8217;).css(&#8216;font-weight&#8217;,&#8217;bold&#8217;);<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>  }<\/p>\n<p>  \u5982\u679c\u53bb\u6389for\u547d\u4ee4 \u662f\u6ca1\u95ee\u9898 \u53ef\u4ee5\u6267\u884c<\/p>\n<p>  \u4f46\u662f\u52a0\u5165for\u547d\u4ee4console.log(ii); \u8f93\u51fa\u90fd\u4e3a$(&quot;.newBarcode&quot;).length -1 \u7684\u503c<\/p>\n<p>  \u5230\u5e95\u54ea\u91cc\u95ee\u9898<\/p>\n<p>  \u5982\u679c\u662fconsole.log(ii) \u653e\u5230getJSON\u4e4b\u524d\u662f\u53ef\u4ee5\u8f93\u51fa\u6bcf\u4e2a ii \u503c\u8bf4\u6765 \u8fd9\u4e2a\u53c8\u662f\u6ca1\u95ee\u9898\u5230\u5e95\u662f\u54ea\u91cc\u51fa\u95ee\u4e86\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>x1184<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:31:17\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u4f5c\u7528\u57df\u95ee\u9898\u5427 \u8bd5\u4e0bfor (let i = 0; i &lt; $(&quot;.newBarcode&quot;).length; i++)\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>u2u<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:38:26\t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 u2u \u4e8e 2020-3-24 17:39 \u7f16\u8f91 <\/p>\n<p> \u56e0\u4e3agetJSON\u662f\u5f02\u6b65\u7684\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c31\u662f\u4ed6\u6709\u53ef\u80fd\u4f1a\u5728\u4f60\u6574\u4e2afor\u6267\u884c\u5b8c\u6bd5\u540e\u518d\u6162\u60a0\u60a0\u7684\u8fdb\u884c\u7f51\u7edc\u8fde\u63a5\uff0c\u6267\u884c\u91cc\u9762\u7684\u5185\u5bb9\u3002\u6240\u6709\u4f60\u9700\u8981\u6539\u6210\u540c\u6b65\u6267\u884c\uff0c\u628a\u4f60\u7684\u4ee3\u7801\u653e\u5230\u4e0b\u9762\u8fd9\u4e24\u884c\u4e4b\u95f4\u5c31\u884c\u3002<\/p>\n<p>  $.ajaxSettings.async = false;<br \/>  &#8230;&#8230;..<br \/>  $.ajaxSettings.async = true;\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u9038\u7b19<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:40:39\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5f02\u6b65\u95ee\u9898<br \/>  for \u5b83\u4e0d\u7b49\u4f60 get \u67d0\u4e2aurl\u7684\uff0c\u5b83\u81ea\u5df1for \u5b8c\u4e86\uff0c\u503c\u5df2\u7ecf\u662flenth-1\u4e86\uff0c<br \/>  \u7136\u540e\u4f60\u7b2c\u4e00\u4e2abarcode\u624d\u6536\u5230\u4e86\uff0c\u4e8e\u662fconsole.log\u51fa\u6765\u7684\uff0c\u5c31\u662flenth-1\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>x1184<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:42:31\t<\/p>\n<h3><\/h3>\n<p>  \t\tu2u \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:38<br \/>  \u56e0\u4e3agetJSON\u662f\u5f02\u6b65\u7684\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c31\u662f\u4ed6\u6709\u53ef\u80fd\u4f1a\u5728\u4f60\u6574\u4e2afor\u6267\u884c\u5b8c\u6bd5\u540e\u518d\u6162\u60a0\u60a0\u7684\u8fdb\u884c\u7f51\u7edc\u8fde\u63a5\uff0c\u6267\u884c\u91cc\u9762\u7684 &#8230;<\/p>\n<p> \u770b\u4e86\u4e0b\u786e\u5b9e\u5f02\u6b65\u95ee\u9898 \u4f46\u5f3a\u5236\u6539\u540c\u6b65\u611f\u89c9\u5bf9\u6027\u80fd\u5f88\u5f71\u54cdyc003t\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>ghs9262<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:45:08\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u3002\u3002$.getJSON \u662f\u5f02\u6b65ajax&nbsp; &nbsp;\u4f60\u53ef\u4ee5\u628aii\u4f5c\u4e3a\u53c2\u6570\u653e\u8fdbajax\u51fd\u6570 \u7136\u540e\u7528\u56de\u8c03\u7684\u65f6\u5019\u7528 this.\u53c2\u6570\u540d \u53d6\u51fa\u6765\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u65b0\u7f51\u7edc<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:45:38\t<\/p>\n<h3><\/h3>\n<p>  \t\tu2u \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:38<br \/>  \u56e0\u4e3agetJSON\u662f\u5f02\u6b65\u7684\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c31\u662f\u4ed6\u6709\u53ef\u80fd\u4f1a\u5728\u4f60\u6574\u4e2afor\u6267\u884c\u5b8c\u6bd5\u540e\u518d\u6162\u60a0\u60a0\u7684\u8fdb\u884c\u7f51\u7edc\u8fde\u63a5\uff0c\u6267\u884c\u91cc\u9762\u7684 &#8230;<\/p>\n<p> \u539f\u6765\u662f\u8fd9\u6837\uff0c\u8c22\u8c22\u5927\u4f6c\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u9038\u7b19<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-3-24 17:45:57\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u90a3\u6211\u6765\u8bf4\u4e2a\u83dc\u9e1f\u7684\u89e3\u51b3\u65b9\u6848\uff1a<br \/>  for (i) {<br \/>  &nbsp; &nbsp; bc=xxxxx;<br \/>  &nbsp; &nbsp; ii=xxxxx;<br \/>  &nbsp; &nbsp; if (xxxx) barcode(bc, ii);<br \/>  }<\/p>\n<p>  function barcode(a, b)<br \/>  {<br \/>  getJSON(xxxxxxx);<br \/>  xxxxxxxxxxxx<br \/>  }\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u7f51\u7edc \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/61230"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61230"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/61230\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61230"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}