JavaScript-embed PHP code in JS string, add to page is commented out

Source: Internet
Author: User

Need to take value from the background database, in the SELECT tag to traverse the data inside the database


  
       选择商品编号
   
                 
    
         
   
     

The default select tag has only one

Click the plus sign below to add a row of data

the problem comes!!! Here we use the JS code to define a string , and then use the append of JQ to add to the node , generate a data table, but this time the select tag how to traverse the database , the PHP code written into the JS string inside, added to the page after the comment out , does not work.

So what's the best way to solve this?!!
So what's the best way to solve this?!!
So what's the best way to solve this?!!

Reply content:

Need to take value from the background database, in the SELECT tag to traverse the data inside the database


  
       选择商品编号
   
                 
    
         
   
     

The default select tag has only one

Click the plus sign below to add a row of data

the problem comes!!! Here we use the JS code to define a string , and then use the append of JQ to add to the node , generate a data table, but this time the select tag how to traverse the database , the PHP code written into the JS string inside, added to the page after the comment out , does not work.

So what's the best way to solve this?!!
So what's the best way to solve this?!!
So what's the best way to solve this?!!

Try it, I'm not testing.


  
       选择商品编号        
    
         
  
   

Here's what I wrote:

 
  
           
  
                     
  
           

Your writing is too magical, JS and do not know PHP tags, of course, can not ...

Of course, if you put the code directly in the PHP file, with the script tag is also possible, but definitely not put in the JS file ...

The ideal way to do this is to use PHP to output the data in JSON format, and then JS parse the JSON, splicing code

  • Related Article

    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.