Twig Use JS variable method, twig use JS variable
In this paper, we describe the method of using JS variable in twig. Share to everyone for your reference, as follows:
Look at a piece of code first
The address of this AJAX request is not properly accessible.
In this code, JQuery ("#my_input"). Val () values are assigned to value, and then you want to introduce the value variable into the URL address in Ajax.
At this point you will find that the value of the address you are visiting is not introduced, but is treated as a string.
That is, the value of JS can not be directly quoted in the Twig.
The reason is that twig parses a PHP variable, and value is a JS variable, so twig is considered a string by default.
So we need to replace, we'll use replace.
The code below, you can compare with the above code itself:
Permanent address of this article: http://blog.it985.com/7020.html
This article is from IT985 blog, please indicate the source and corresponding link when reproduced.
More about PHP template related content readers can view the site topics: "PHP Template Technology Summary", "Smarty Template Primer Basic Tutorial", "CodeIgniter Introductory Tutorial" and "thinkphp Introductory tutorial"
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- Twig Template Common Statement instance summary
- Twig template engine usage Getting Started tutorial
- Examples of using the PHP template engine twig in the YII framework
- How to get global variables twig templates
http://www.bkjia.com/PHPjc/1099083.html www.bkjia.com true http://www.bkjia.com/PHPjc/1099083.html techarticle The method of using JS variable in twig, twig using JS variable, this paper describes the method of using JS variable in twig. Share to everyone for reference, as follows: First look at a piece of code ...