admin管理员组文章数量:1357712
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");
本文标签: jqueryHow to append data from load() function to div using javascriptStack Overflow
版权声明:本文标题:jquery - How to append data from .load() function to div using javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744080409a2587529.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论