简体   繁体   English

jQuery,Ajax,将发布结果加载到div

[英]jquery, ajax, load post result to div

I have a form that I need to post and show the result in a div. 我有一个表格需要发布并在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. 我在进行ajax调用时没有任何问题,但似乎无法弄清楚如何将结果加载到div。 I have tried: 我努力了:

$.ajax({
    type: 'POST',
    data: $('#someForm').serialize(),
    url: 'http://somedomain.com/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. 我确定这是否应该工作,但结果是我从加载到div中发布的页面,而不是我要发布到的URL。

Any help would be great! 任何帮助都会很棒! Thanks! 谢谢!

If the "result" is just HTML, then you'd say 如果“结果”只是HTML,那么您会说

$('#someDiv').html(data);

If you want it treated strictly as plain text: 如果要严格将其视为纯文本:

$('#someDiv').text(data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM