admin 管理员组文章数量: 1086019
I have a form that I need to post and show the result in a div. I'm not having any problems making the ajax call but I can't seem to figure out how to load the result to a div. I have tried:
$.ajax({
type: 'POST',
data: $('#someForm').serialize(),
url: '',
success: function(data) {
$('#someDiv').load(data);
}
});
but it does not seem to work properly. I'm nit sure if this should even work but the result is the the page i'm posting from being loaded into the div and not the url I'm posting to.
Any help would be great! Thanks!
I have a form that I need to post and show the result in a div. I'm not having any problems making the ajax call but I can't seem to figure out how to load the result to a div. I have tried:
$.ajax({
type: 'POST',
data: $('#someForm').serialize(),
url: 'http://somedomain./my/url',
success: function(data) {
$('#someDiv').load(data);
}
});
but it does not seem to work properly. I'm nit sure if this should even work but the result is the the page i'm posting from being loaded into the div and not the url I'm posting to.
Any help would be great! Thanks!
Share Improve this question asked Jun 11, 2010 at 16:16 mikemike 8,14119 gold badges55 silver badges68 bronze badges 2-
1
Have you verified that the data is successfully being returned? You could test in the
success
callback withconsole.log(data)
oralert(data)
. – user113716 Commented Jun 11, 2010 at 16:28 - Actually, I just figured out that there is a problem on the backend... Got it working with something else. Thanks ! – mike Commented Jun 11, 2010 at 16:44
1 Answer
Reset to default 11If the "result" is just HTML, then you'd say
$('#someDiv').html(data);
If you want it treated strictly as plain text:
$('#someDiv').text(data);
本文标签: JavaScriptJQuery Ajax load post result to divStack Overflow
版权声明:本文标题:javascript - jquery, ajax, load post result to div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1741017628a2240920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论