{"id":12124,"date":"2019-09-11T21:46:48","date_gmt":"2019-09-12T02:46:48","guid":{"rendered":"httpss:\/\/www.powenko.com\/wordpress\/?p=12124"},"modified":"2019-09-11T21:48:48","modified_gmt":"2019-09-12T02:48:48","slug":"jquery-ajax","status":"publish","type":"post","link":"https:\/\/www.powenko.com\/wordpress\/?p=12124","title":{"rendered":"01 Jquery AJAX"},"content":{"rendered":"<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">        function displayData_datalist(tID,file,field,whereString) {\r\n\r\n            t_url=&quot;&lt;?=AWS?&gt;\/ETC\/system\/04_AWS\/06_%E6%9F%A5%E8%A9%A2%E8%A1%A8%E6%A0%BC\/04_webservice_json.php?action=select&amp;file=&quot;+file+&quot;&amp;field=&quot;+field;\r\n            console.log(t_url);\r\n            $.ajax({\r\n                url: '&lt;?=$path?&gt;\/04_AWS\/06_\u67e5\u8a62\u8868\u683c\/04_webservice_json.php?action=select&amp;field='+field,\r\n                data: {'url':encodeURI(t_url),'tID':tID,'file':file,'field':field,'where':whereString},\r\n                type: 'GET',\r\n                contentType: &quot;application\/x-www-form-urlencoded; charset=utf-8&quot;,\r\n                dataType:'json',\r\n                async:true,\r\n                success : function(data) {\r\n                    if(tID!=&quot;\u59d4\u8a17\u9805\u76ee1_list&quot;)\r\n                    {\r\n                        var nameArray = data&#x5B;'data'];\r\n                        var lastvalue = null;\r\n                        $.each(nameArray, function (i, item) {\r\n                            t1 = &quot;#&quot; + tID;\r\n                            \/\/console.log(item&#x5B;field]);\r\n                            if (lastvalue != item&#x5B;field]) {\r\n                                $(t1).append($(&quot;&lt;option&gt;&quot;).attr('value', item&#x5B;field]).text(item&#x5B;field]));\r\n                                lastvalue = item&#x5B;field];\r\n                            }\r\n                        });\r\n                    }\r\n                },\r\n                error : function(request,error)\r\n                { console.log(&quot;error&quot;);\r\n                }\r\n            });\r\n        }\r\n<\/pre>\n<p>\u800cPHP\u90a3\u908a<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n$fxls = isset($_GET&#x5B;'file']) ? $_GET&#x5B;'file'] : 'test.xls';\r\n$fxls2 ='files\/'.$fxls;\r\n$action = isset($_GET&#x5B;'action']) ? $_GET&#x5B;'action'] : 'select';\r\n$ext = strtolower(pathinfo($fxls2 , PATHINFO_EXTENSION));\r\n$tID = isset($_GET&#x5B;'tID']) ? $_GET&#x5B;'tID'] : '';\r\n$file = isset($_GET&#x5B;'file']) ? $_GET&#x5B;'file'] : '';\r\n$field = isset($_GET&#x5B;'field']) ? $_GET&#x5B;'field'] : '';\r\n$where = isset($_GET&#x5B;'where']) ? $_GET&#x5B;'where'] : '';\r\n\r\n    if (is_array($arr)==true &amp;&amp;  count($arr) &gt; 0) {\r\n        echo json_encode(array(\r\n            &quot;success&quot; =&gt; true,\r\n            &quot;id&quot; =&gt; 1909051,\r\n            &quot;data&quot; =&gt; $arr,\r\n            &quot;debug&quot; =&gt; $field,\r\n            &quot;msg&quot; =&gt; $msg,\r\n            &quot;filename&quot; =&gt;$fxls,\r\n            &quot;tID&quot; =&gt;$tID,\r\n            &quot;file&quot; =&gt;$file,\r\n            &quot;field&quot; =&gt;$field,\r\n            &quot;where&quot; =&gt;$where,\r\n            \/\/&quot;msg&quot; =&gt; &quot;OK&quot;,\r\n        ));\r\n    } else {\r\n        echo json_encode(array(\r\n            &quot;success&quot; =&gt; false,\r\n            &quot;id&quot; =&gt; 1908273,\r\n            &quot;debug&quot; =&gt; &quot;file name:&quot; . $fxls,\r\n            &quot;debug&quot; =&gt; $msg,\r\n            &quot;msg&quot; =&gt; $msg,\r\n            \/\/&quot;msg&quot; =&gt; &quot;error&quot;,\r\n        ));\r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function displayData_datalist(tID,file,field,whereStrin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[549],"tags":[],"class_list":["post-12124","post","type-post","status-publish","format-standard","hentry","category-ch10-ajax-javascript"],"_links":{"self":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12124"}],"collection":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12124"}],"version-history":[{"count":2,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12124\/revisions"}],"predecessor-version":[{"id":12126,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/12124\/revisions\/12126"}],"wp:attachment":[{"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.powenko.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}