Hi all :)
I basically want to use the .append() data to append the data that I got to the selected div.
this is variable that i've declared
var li_template = '<div style="display:none" class="load_reply"><div class="reply_img"><img src="status/blankSilhouette.png" /></div><div class="reply_text"><a href="#" class="blue">Test Name</a><p class="tex">%s</p><div class="date">%r · <a href="#" class="light_blue">Like</a> · <a href="#" class="light_blue">Comment</a></div></div><div class="clear"></div></div>';
and below is my ajax code :
$.ajax({
type: "POST",
url: "reply.php",
data: $this.serialize(),//easier than building the string manually.
success: function(discuss_text,date){
var data1 = $(li_template.replace('%s',discuss_text));
var data2 = $(li_template.replace('%r',date));
var combine = $add(data1,data2);
$(data1+data2).prependTo($reply_text).fadeIn();//insert, then fadeIn a new li element and its contents.
$this.val('');//empty the textarea
},
error: function(){
//you should display something to advise the user if ajax fails.
},
complete: function(){
//something here...
}
});
so if you notice on the code above, I've tried to combine two varibales and append them to the $reply_text.which i've tried to do by writing like this :
var data1 = $(li_template.replace('%s',discuss_text));
var data2 = $(li_template.replace('%r',date));
var combine = $add(data1,data2);
$(data1+data2).prependTo($reply_text).fadeIn();
I know that my attempt is wrong,and I hope you guys could show me the real way to do this.
So any help guys??