The particularity of volist tags in thinkphp in ajax operation of recommendation

  • 2021-08-31 07:34:35
  • OfStack

Background

Realize the volist tab to display the return of Jquery query results in a complex page of ThinkPHP (including volist)

Knowledge point

The purpose of using ajax is to refresh some table data without refreshing the whole page, but note that the volist tag in ThinkPHP framework runs on the server side, so the data dynamically obtained by using js cannot use thinkPHP tag, and it is impossible to use thinkPHP tag $this->ajaxReturn($data); The results of the direct use of $("#div_id").HTML(data) Displays the method of.

The solutions found so far (all have defects)

1. Create a new page to display

Reopen a jump page and return the value as $this- > assign ("volist_name", $data); Returns in the way of.

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

2. Display without the label of thinkPHP frame

The result returned by ajaxReturn is analyzed without volist tag, and displayed according to template template of js, which can realize local form update

1. template template <script id="events-template" type="x-tmpl-mustache">     {{#data}}      

Summarize


Related articles: