<script>varId=1;//This ID must have, if it is a null value, cannot be interacted with. A little depressed .... varJSON; $.ajax ({URL:".. /member/wenzhanglishi.php",//here, fill in your PHP operation page, which is the PHP page that accepts the JS parameter. Type"POST",//here and PHP to take care of, here fill post,php will use $_post[] accept! data:{"Jsdata": ID},//pass past the parameters, I pass an ID, accept when the PHP write: $data =$_post["Jsdata"]; variable names can of course be changed. Error:function () {//Error HandlingAlert'Request timed out'); }, Success:function (data)//after the successful function, note that the parameters returned by PHP are accepted here!!!! { //The data has stored three arrays, which are members, articles, and numbers, and now how do you get the values out? //Attention!! Since the Base64 encryption is performed at the time of the pass, the parameters you pass through and the parameters returned are very long, and if we do not use JSON, the parameters will be lost as part of the length limit! So we have to relate to a troublesome thing JSON arrayalert (data); } }); </script>
Above is the HTML page JS code, the following is the code of the PHP page
<?php require_once (dirname (__file__)."/config.php"); $data=$_post["Jsdata"]; $list 1=mysql_query ("select* from Dede_shenhe"); $bianhao=Array (); $biaoti=Array (); $lishi=Array (); while($rows =mysql_fetch_array ($list 1)) {$bianhao []= $rows ['Aid']; $biaoti []= $rows ['Tittle']; $lishi []= $rows ['Huiyuan']; }Echo Json_encode ($bianhao), Json_encode ($biaoti), Json_encode ($lishi); This part is the data returned with JSON, but in JS I have not learned how to receive, haha /*Echo Json_encode ($biaoti);*/?>
JS uses Ajax and Jison to transfer values between PHP and HTML on different pages.