What are the precautions for using the volist tag in Ajax in thinkphp?

php中世界最好的语言
Release: 2023-03-26 22:42:01
Original
1346 people have browsed it

This time I will bring you what are the precautions when using the volist tag in thinkphp in ajax. The following is a practical case, let’s take a look.

Background

Implement the volist tag to display Jqueryquery results in a complex ThinkPHP page (including volist) Return

Knowledge points

The purpose of using ajax is to refresh some table data without refreshing the entire page, but pay attention to Think# The volist tag in ##PHP framework runs on the server side, so the data dynamically obtained using js cannot use the thinkPHP tag, and $this->ajaxReturn<a href="http://www.php.cn/wiki/135.html" target="_blank">( $data); The result of </a> is displayed directly using the method $("#p_id").HTML(data) .

Solutions found so far (all have flaws)

1. Create a new page for display

Reopen a jump page and you will be returned The value is returned in the form of $this->assign("volist_name", $data);.

**Defect: It is equivalent to reloading the entire page, and does not meet the requirement of partially updating the form.

2. Display without thinkPHP framework tags

Do not use volist tags, analyze the results returned by ajaxReturn, and display them according to your own js template, which can realize partial form updates

1,template template

 <script id="events-template" type="x-tmpl-mustache">     {{#data}}
Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of the steps to print a binary tree in Z-shaped order with PHP

How to make a watermark and generate abbreviation in PHP Sketch class

#PHP Detailed explanation of the steps to obtain the nodes of the linked list from back to front

The above is the detailed content of What are the precautions for using the volist tag in Ajax in thinkphp?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!