JS uses Ajax and Jison to transfer values between PHP and HTML on different pages.

Source: Internet
Author: User
Tags php write

<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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.