I want to append the results of an Ajax request to a table I have on my page. I see 2 ways of rendering the rows :
my Controller could return a JSon array that I will then decode in the view and create a Javascript function to properly add the adequate HTML markup
my Controller could directly return the HTML
What is the best practice on that matter?
I usually use that ways
Send ajax to PHP file with dataType: 'json'
At PHP
: I processing data and json_encode the data array and die it to return result to HTML
on Success function of Ajax, i process the data
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.