{"id":954,"date":"2010-03-13T15:17:00","date_gmt":"2010-03-13T07:17:00","guid":{"rendered":""},"modified":"2013-11-17T16:03:46","modified_gmt":"2013-11-17T08:03:46","slug":"%e6%b1%82%e8%a7%a3%e4%b9%9d%e5%ae%ab%e6%a0%bc%e7%9a%84web%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/954.html","title":{"rendered":"\u6c42\u89e3\u4e5d\u5bab\u683c\u7684WEB\u5e94\u7528\u7a0b\u5e8f"},"content":{"rendered":"<p>\u6628\u5929\u60f3\u4e86\u4e00\u4e2a\u70b9\u5b50\uff0c\u5229\u7528Delphi\u7684DataSnap\uff0c\u7ed3\u5408HTML\u4e0eJavaScript\uff0c\u7528AJAX\u6280\u672f\uff0c\u5b9e\u73b0WEB\u5e94\u7528\u7a0b\u5e8f\u3002\u4eca\u5929\u53c8\u505a\u4e86\u4e00\u4e2a\u5b9e\u9a8c\u7a0b\u5e8f\uff0c\u6bd4\u8f83\u6210\u529f\u3002\u5177\u4f53\u65b9\u6cd5\u4e0d\u591a\u8bf4\u4e86\uff0c\u4e0a\u4e00\u7bc7\u5df2\u7ecf\u8bb2\u8fc7\uff0c\u76f4\u63a5\u5e16\u4e0a\u5173\u952e\u4ee3\u7801\u3002<\/p>\n<div>\n<p>DataSnap\u7684CGI\u7a0b\u5e8f\u4ee3\u7801(ServerMethod\u5355\u5143)\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nunit ServerMethodsUnit1;\r\n\r\ninterface\r\n\r\nuses\r\n  SysUtils, Classes, DSServer, DBXJSON;\r\n\r\nvar\r\n  GG: array&#x5B;0..8] of array&#x5B;0..8] of Integer;\r\nconst\r\n  QQ:array&#x5B;0..8] of integer=(0,0,0,3,3,3,6,6,6);\r\nvar\r\n  GG2: TJSONObject;\r\n\r\ntype\r\n{$METHODINFO ON}\r\n  JSShuDu = class(TPersistent)\r\n  private\r\n    { Private declarations }\r\n  public\r\n    { Public declarations }\r\n    function EchoString(Value: string): string;\r\n    function JieSuan(shudu: string): TJSONObject;\r\n  end;\r\n{$METHODINFO OFF}\r\nfunction IsValid(i,j:integer):boolean;\r\nprocedure calc(n:integer);\r\nfunction OutGG: TJSONObject;\r\nprocedure SetGG(shudu: string);\r\n\r\nimplementation\r\n\/\/\u68c0\u67e5\u4e5d\u5bab\u683c\u662f\u5426\u5408\u683c\r\nfunction IsValid(i,j:integer):boolean;\r\nvar n,t,u:integer;\r\nbegin\r\n  Result:=true;\r\n  n:=GG&#x5B;i,j];\r\n  for t := 0 to 9 - 1 do\r\n    if(((t&lt;&gt;i) and (GG&#x5B;t,j]=n)) or ((t&lt;&gt;j) and (GG&#x5B;i,t]=n))) then result:=false;\r\n\r\n  for t := QQ&#x5B;i] to QQ&#x5B;i]+2 do\r\n    for u := QQ&#x5B;j] to QQ&#x5B;j] +2 do\r\n      if(((t&lt;&gt;i) or (u&lt;&gt;j)) and (GG&#x5B;t,u]=n)) then result:=false;\r\nend;\r\n\/\/\u89e3\u7b97\u4e5d\u5bab\u683c\r\nprocedure calc(n:integer);\r\nvar i,j,k:integer;\r\nbegin\r\n  if(n=81) then\r\n  begin\r\n    GG2 := OutGG;\r\n    Exit;\r\n  end;\r\n\r\n  i:=n div 9; j:=n mod 9;\r\n\r\n  if(GG&#x5B;i,j]&lt;&gt;0) then\r\n  begin\r\n    calc(n+1);\r\n    exit;\r\n  end;\r\n\r\n  for k := 0 to 9 - 1 do\r\n  begin\r\n    GG&#x5B;i,j]:=GG&#x5B;i,j]+1;\r\n    if(IsValid(i,j)) then\r\n    begin\r\n      calc(n+1);\r\n    end;\r\n  end;\r\n\r\n  GG&#x5B;i,j]:=0;\r\nend;\r\n\/\/\u4ee5JSON\u683c\u5f0f\u5c06\u4e5d\u5bab\u683c\u8f93\u51fa\r\nfunction OutGG: TJSONObject;\r\nvar\r\n  I: Integer;\r\n  j,temp: Integer;\r\nbegin\r\n  Result := TJSONObject.Create;\r\n  temp := 1;\r\n  for I := 0 to 9 - 1 do\r\n    for j := 0 to 9 - 1 do\r\n      begin\r\n        Result.AddPair(TJSONPair.Create('id'+IntToStr(temp),IntToStr(GG&#x5B;i,j])));\r\n        temp := temp+1;\r\n      end;\r\nend;\r\n\/\/\u521d\u59cb\u5316\u4e5d\u5bab\u683c\u6570\u7ec4\r\nprocedure SetGG(shudu: string);\r\nvar\r\n  I: Integer;\r\n  j: Integer;\r\nbegin\r\n  for I := 0 to 9 - 1 do\r\n    for j := 0 to 9 - 1 do\r\n      begin\r\n        GG&#x5B;i,j] := StrToInt(Copy(shudu,1,1));\r\n        shudu := Copy(shudu,2,Length(shudu)-1);\r\n      end;\r\nend;\r\n\r\nfunction JSShuDu.JieSuan(shudu: string): TJSONObject;\r\nbegin\r\n  SetGG(shudu);\r\n  calc(0);\r\n  Result := GG2;\r\nend;\r\n\r\nfunction JSShuDu.EchoString(Value: string): string;\r\nbegin\r\n  Result := Value;\r\nend;\r\n\r\nend.\r\n<\/pre>\n<p>HTML\u7248\u7684\u5ba2\u670d\u7aef\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&quot; &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&quot;&gt;\r\n\r\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot;&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=utf-8&quot; \/&gt;\r\n\r\n&lt;title&gt;\u89e3\u7b97\u6570\u72ec&lt;\/title&gt;\r\n\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;JQuery.js&quot;&gt;&lt;\/script&gt;\r\n\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\n\r\ninput{width:25px; margin:5px 5px;}\r\n\r\ndiv{text-align:center; margin-top:50px;}\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n\r\n$(document).ready(function(){   \/\/\u9875\u9762\u52a0\u8f7d\u65f6\u88c5\u5165\u6570\u636e\r\n\r\nvar text=\u2019040203050580001003000000002000000000650000890300006000200704000863000007009360000\u2032;\r\n\r\nvar j=0;\r\n\r\n$(&quot;input&quot;).each(function(){\r\n\r\n         $(this).val(text&#x5B;j]);\r\n\r\n         j++;\r\n\r\n         })\r\n\r\n});\r\n\r\nfunction JieSD()\r\n\r\n{\r\n\r\nvar text=\u201d;\r\n\r\n$(&quot;input&quot;).each(function(){\r\n\r\n        text=text+$(this).val();\r\n\r\n        });\r\n\r\ntext=text.substring(0,text.length-2); \/\/\u53bb\u6389input\u6309\u94ae\u7684\u5b57\r\n\r\nif(text==&quot;&quot;){text=\u2019040203050580001003000000002000000000650000890300006000200704000863000007009360000\u2032;}\r\n\r\n\/\/alert(text);\r\n\r\n$.ajax({\r\n\r\n      type:&quot;get&quot;,\r\n\r\n      url:&quot;http:\/\/127.0.0.1\/cgi-bin\/ShuDu.exe\/DataSnap\/rest\/JSShuDu\/jiesuan\/&quot;+text,\r\n\r\n      dataType:&quot;json&quot;,\r\n\r\n      success:function(data){\r\n\r\n       var i=1;\r\n\r\n        $(&quot;input&quot;).each(function(){                     \/\/\u904d\u5386\u6240\u6709\u7684input\u6846\r\n\r\n        $(this).val(data.result&#x5B;0]&#x5B;&quot;id&quot;+i]); \/\/\u5e38\u91cf\u4e0e\u53d8\u91cf\u8fde\u63a5:&quot;id&quot;+i\r\n\r\n        i++;\r\n\r\n        });\r\n\r\n      $(\u2018#button\u2019).val(\u2018\u6c42\u89e3\u2019);                       \/\/\u6062\u590dinput\u6309\u94ae\u7684\u5b57\r\n\r\n      }\r\n\r\n      });\r\n\r\n}\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;div&gt;\r\n\r\n&lt;h3&gt;\u8f93\u5165\u4e5d\u5bab\u683c\u6570\u72ec\uff0c\u75280\u4ee3\u66ff\u8981\u6c42\u7684\u6570&lt;\/h3&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;div id=&quot;main&quot;&gt;\r\n\r\n&lt;input id=&quot;id1&quot; \/&gt;&lt;input id=&quot;id2&quot; \/&gt;&lt;input id=&quot;id3&quot; \/&gt;&lt;input id=&quot;id4&quot; \/&gt;&lt;input id=&quot;id5&quot; \/&gt;&lt;input id=&quot;id6&quot; \/&gt;&lt;input id=&quot;id7&quot; \/&gt;&lt;input id=&quot;id8&quot; \/&gt;&lt;input id=&quot;id9&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id10&quot; \/&gt;&lt;input id=&quot;id11&quot; \/&gt;&lt;input id=&quot;id12&quot; \/&gt;&lt;input id=&quot;id13&quot; \/&gt;&lt;input id=&quot;id14&quot; \/&gt;&lt;input id=&quot;id15&quot; \/&gt;&lt;input id=&quot;id16&quot; \/&gt;&lt;input id=&quot;id17&quot; \/&gt;&lt;input id=&quot;id18&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id19&quot; \/&gt;&lt;input id=&quot;id20&quot; \/&gt;&lt;input id=&quot;id21&quot; \/&gt;&lt;input id=&quot;id22&quot; \/&gt;&lt;input id=&quot;id23&quot; \/&gt;&lt;input id=&quot;id24&quot; \/&gt;&lt;input id=&quot;id25&quot; \/&gt;&lt;input id=&quot;id26&quot; \/&gt;&lt;input id=&quot;id27&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id28&quot; \/&gt;&lt;input id=&quot;id29&quot; \/&gt;&lt;input id=&quot;id30&quot; \/&gt;&lt;input id=&quot;id31&quot; \/&gt;&lt;input id=&quot;id32&quot; \/&gt;&lt;input id=&quot;id33&quot; \/&gt;&lt;input id=&quot;id34&quot; \/&gt;&lt;input id=&quot;id35&quot; \/&gt;&lt;input id=&quot;id36&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id37&quot; \/&gt;&lt;input id=&quot;id38&quot; \/&gt;&lt;input id=&quot;id39&quot; \/&gt;&lt;input id=&quot;id40&quot; \/&gt;&lt;input id=&quot;id41&quot; \/&gt;&lt;input id=&quot;id42&quot; \/&gt;&lt;input id=&quot;id43&quot; \/&gt;&lt;input id=&quot;id44&quot; \/&gt;&lt;input id=&quot;id45&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id46&quot; \/&gt;&lt;input id=&quot;id47&quot; \/&gt;&lt;input id=&quot;id48&quot; \/&gt;&lt;input id=&quot;id49&quot; \/&gt;&lt;input id=&quot;id50&quot; \/&gt;&lt;input id=&quot;id51&quot; \/&gt;&lt;input id=&quot;id52&quot; \/&gt;&lt;input id=&quot;id53&quot; \/&gt;&lt;input id=&quot;id54&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id55&quot; \/&gt;&lt;input id=&quot;id56&quot; \/&gt;&lt;input id=&quot;id57&quot; \/&gt;&lt;input id=&quot;id58&quot; \/&gt;&lt;input id=&quot;id59&quot; \/&gt;&lt;input id=&quot;id60&quot; \/&gt;&lt;input id=&quot;id61&quot; \/&gt;&lt;input id=&quot;id62&quot; \/&gt;&lt;input id=&quot;id63&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id64&quot; \/&gt;&lt;input id=&quot;id65&quot; \/&gt;&lt;input id=&quot;id66&quot; \/&gt;&lt;input id=&quot;id67&quot; \/&gt;&lt;input id=&quot;id68&quot; \/&gt;&lt;input id=&quot;id69&quot; \/&gt;&lt;input id=&quot;id70&quot; \/&gt;&lt;input id=&quot;id71&quot; \/&gt;&lt;input id=&quot;id72&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input id=&quot;id73&quot; \/&gt;&lt;input id=&quot;id74&quot; \/&gt;&lt;input id=&quot;id75&quot; \/&gt;&lt;input id=&quot;id76&quot; \/&gt;&lt;input id=&quot;id77&quot; \/&gt;&lt;input id=&quot;id78&quot; \/&gt;&lt;input id=&quot;id79&quot; \/&gt;&lt;input id=&quot;id80&quot; \/&gt;&lt;input id=&quot;id81&quot; \/&gt;&lt;br \/&gt;\r\n\r\n&lt;input type=&quot;button&quot; id=&quot;button&quot; value=&quot;\u6c42\u89e3&quot; style=&quot;width:80px;&quot; onclick=&quot;JieSD();&quot;\/&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><img decoding=\"async\" src=\".\/wp-content\/uploads\/hibaidu\/0e3d34f217389d65342acc57.jpg\" alt=\"\" border=\"0\" \/>\u622a\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\".\/wp-content\/uploads\/hibaidu\/b40e8945c62c7879500ffe2c.jpg\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u6b32\u6c42\u89e3\u7684\u4e5d\u5bab\u683c<\/p>\n<p><img decoding=\"async\" src=\".\/wp-content\/uploads\/hibaidu\/1e23a6d268422301970a16b5.jpg\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u6c42\u89e3\u540e\u7684\u4e5d\u5bab\u683c<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u5929\u60f3\u4e86\u4e00\u4e2a\u70b9\u5b50\uff0c\u5229\u7528Delphi\u7684DataSnap\uff0c\u7ed3\u5408HTML\u4e0eJavaScript\uff0c\u7528AJAX\u6280\u672f\uff0c\u5b9e\u73b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-954","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=954"}],"version-history":[{"count":2,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/954\/revisions"}],"predecessor-version":[{"id":4648,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/954\/revisions\/4648"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}