The comment information is loaded when you first enter the details page, but every time you post a comment, if you do not refresh the page, the comment content cannot be loaded. What should I do through ajax?
It has been implemented, let me talk about the idea, teacher, see if this is appropriate
1. When loading the details page, follow the background query and template assignment method, and implement the first load through volist in the foreground
2 , post a comment after entering the details page, submit a new comment through ajax at the front desk, execute the new comment in the background and obtain the data from multiple tables after success and return it to the template
3. After the front desk receives the returned data, it passes through a for loop Traverse the data and load it into the comment list
An interface for publishing comments and an interface for obtaining comment information. After each comment is published, the latest comment content is obtained through ajax again
It has been implemented, let me talk about the idea, teacher, see if this is appropriate
1. When loading the details page, follow the background query and template assignment method, and implement the first load through volist in the foreground
2 , post a comment after entering the details page, submit a new comment through ajax at the front desk, execute the new comment in the background and obtain the data from multiple tables after success and return it to the template
3. After the front desk receives the returned data, it passes through a for loop Traverse the data and load it into the comment list
Front-end code:
if (datas.status == 1) {
}###$('#result').text(datas.message );
var str = "";
$("#comm").html("");
for (var i = 0; i < datas.data.length; i++) {
str = '<div style=\"width: 95%\">' +
'<p>'+ datas.data[i].name +' ' + timestampToTime(datas.data[i].create_time) + '</p>' +
'<div style=\"min-height: 50px;\">' + datas.data[i] .content + '</div>' +
'<hr style=\"margin: 0\">' +
'</div>';
'<hr style=\"margin: 0\">' +
").append(str);
}
$("#comment")[0].reset();
} else {
$('#result').text(datas .message);
An interface for publishing comments and an interface for obtaining comment information. After each comment is published, the latest comment content is obtained through ajax again