Data transmission between the smarty template and php
Source: Internet
Author: User
I made a page for the data transfer problem between the smarty template and php, and used the smarty template. The data is read in index. php and displayed in the index. tpl file. However, the tpl file has a button to sort the data in the specified order. For example, in index. php, the read sequence from the database is 1, 2, 3, and 4 by default. There is a button in the tpl file. after clicking it, there is a data transfer problem between the smarty template and php.
I made a page using the smarty template. The data is read in index. php and displayed in the index. tpl file. However, the tpl file has a button to sort the data in the specified order. For example, in index. php, the read sequence from the database is 1, 2, 3, and 4 by default. There is a button in the tpl file. after you click the button, the page is displayed as 4, 3, 2, and 1. At present, I want to know how to send the click event to index. php, and then index. php reads the data as required, and then displays it in the tpl file.
I wrote a click event in the tpl file. I want to use ajax to transfer the event and capture the packet. index. php also read the data, but the current tpl file is still displayed.
$ ("# Sortbypop"). click (function (){
Var url = document. URL;
$. Get (url, {action: "get", sort: "popsort"}, function (data, textStatus ){
});
});
This is the ajax code. What should I do? Share:
------ Solution --------------------
If you want to use ajax for partial refresh, you have to split the template. Different templates are used for different requirements.
If you want to refresh the entire page, do not use ajax.
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