Sorry if my question confusing, currently i got this working :
success: function(json) {
$('.msgWrapper').load('http://localhost:88/TicketSystem/support/ajaxmsg', {date: json.date, msg: json.msg}).fadeIn("slow");
}
But this only replace my div's content with the data returned by the .load() function, i want to append the data to my div instead of just replacing. Thanks in advance.
Sorry if my question confusing, currently i got this working :
success: function(json) {
$('.msgWrapper').load('http://localhost:88/TicketSystem/support/ajaxmsg', {date: json.date, msg: json.msg}).fadeIn("slow");
}
But this only replace my div's content with the data returned by the .load() function, i want to append the data to my div instead of just replacing. Thanks in advance.
Share Improve this question edited Dec 22, 2012 at 13:19 Eli 14.8k5 gold badges61 silver badges77 bronze badges asked Dec 22, 2012 at 12:06 user1918956user1918956 8971 gold badge8 silver badges11 bronze badges4 Answers
Reset to default 4You can use the jQuery AJAX shorthand post method and to get the data, then just append to your element:
success: function(json){
$.post('http://localhost:88/TicketSystem/support/ajaxmsg', { date: json.date, msg: json.msg }, function(data){
var newData = $('<div>').html(data);
$('.msgWrapper').append(newData);
newData.hide().fadeIn("slow");
};
}
var $temp = $('<div>').load('http://localhost:88/TicketSystem/support/ajaxmsg', {date: json.date, msg: json.msg});
$('.msgWrapper').append($temp.html()).fadeIn("slow");
I'd just send the POST request and append manually:
$.ajax({
url: 'http://localhost:88/TicketSystem/support/ajaxmsg',
type: 'post',
data: {
date: json.date,
msg: json.msg
},
success: function(response) {
$('.msgWrapper').append(response);
}
});
Try this:
$(".msgWrapper").append($("<div>").load('http://localhost:88/TicketSystem/support/ajaxmsg', {date: json.date, msg: json.msg}).fadeIn("slow");
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744080409a4555183.html
评论列表(0条)