php - AJAX overwritting -


i'm using ajax live submit post appended list. problem having when submit post more once, ajax overwrites previous posts submitted.

var data = $("#form_write_post").serialize(); $.ajax({     type: "post",     url: $("#form_write_post").attr("action"),     data: data,     beforesend: function() {         $("ul.timeline").prepend("<img class='textarea_ajax_loading' src='img/ajax-loader.gif' style='margin: 0 auto; display: block;' />");     },     complete: function() {         $('.textarea_ajax_loading').remove();     },     success: function () {         //var successcount = successcount++;         $("ul.timeline").prepend('<li class=ajax_post></li>').fadein();         $("ul.timeline .ajax_post").load("ajax_post.php").fadein();         //$('ul.timeline').prepend(wall_post);         //console.log("success");         return false;     } }); 

how can achieve new post after each submission?

thanks

i'm not sure understand problem, when "ajax overwrites previous posts submitted" assume problem on front-end right?

from code see, might because prepend new <li class=ajax_post></li> , select li class , load in of them.

if want load in latest li, change selector

 $("ul.timeline .ajax_post:first").load("ajax_post.php").fadein(); 

to select first post.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -