Hi,
I’ve asked a similar question yesterday, but now I am trying a different way.
I’ve got a div class called news. It contains some updates from users. When a user submits a new update, I want my new update to be appear at the top of the news class. I tried the following, but it doesn’t work the way I want. When I submit the form, news div is disappear (because my prepend() is empty, but I also want to load the latest.php because it contains this particular user’s last update)
$(document).ready(function () {
$('#new').submit(function (e) {
e.preventDefault();
var form = $(this);
var formData = form.serialize();
$.ajax({
type: 'POST',
url: '/modules/feed/process.php', // the url where we want to POST
data: formData, // our data object
success: function () {
$("#statustext").val(''); // I reset textarea's value here
$(".news").prepend().load("/modules/feed/latest.php"); // I want to load latest.php at the top of the news div but I can't, because prepend() is empty. If I load it without prepend, the new status appears but the other updates disappear.
}
});
});
});