JSON advanced Article 2 transfer JSON data using AJAX

Source: Internet
Author: User
The previous article "JSON advanced article 1 using JSON in PHP and javascript" demonstrates how to use JSON data in PHP and javascript, this article describes how to use AJAX to obtain JSON data to dynamically generate titles and prompt statements. This technology sends requests to the website background on a static page... syntaxHighlighte's previous article "JSON advanced article 1 using JSON in PHP and javascript" demonstrates how to use JSON data in PHP and javascript, this article describes how to use AJAX to obtain JSON data to dynamically generate titles and prompt statements. This technology is effective when a static page requests dynamic data from the website background. because the website homepage has a large volume of traffic, the whole page must be statically processed, however, some data on this page must be updated in real time. in this case, AJAX can be used in static pages to request the JSON data generated in real time in the background. For more information about AJAX technology, see PHP advanced AJAX technology for MySql database access. here we will detail how to use AJAX to transmit JSON data.
 
 
 
This example contains json2.php and json2.html. a button is displayed on json2.html. after you press the button, an AJAX request is sent to obtain the data returned by json2.php.
 
1. json2.php
 
[Php]
// By MoreWindows (http://blog.csdn.net/MoreWindows)
$ Article_array = array (
"Count" => 3,
Array (
"Id" => "001 ",
"Title" => "accessing MySql database using PHP ",
"Link" => "http://www.2cto.com/kf/201112/115227.html"
),
Array (
"Id" => "001 ",
"Title" => "accessing MySql database using PHP intermediate Smarty technology ",
"Link" => "http://www.2cto.com/kf/201112/115229.html"
),
Array (
"Id" => "001 ",
"Title" => "PHP advanced AJAX technology for MySql database access ",
"Link" => "http://www.2cto.com/kf/201112/115230.html"
),
);
$ Article_json = json_encode ($ article_array );
Echo $ article_json;
?>
2.Json2.html
 
[Html]
 
 
 
Ajax request json 

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.