jQuery的,阿贾克斯,负荷后结果div中负荷、结果、jQuery、阿贾克斯

2023-09-10 20:13:27 作者:一生莫轻舞

我有我需要发布和显示结果在一个div一个形式。我并没有使Ajax调用任何问题,但我似乎无法弄清楚如何将结果加载到一个div。我曾尝试:

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.com/my/url',
    success: function(data) {   
        $('#someDiv').load(data);
    }
});

但它似乎并没有正常工作。我NIT知道这甚至应该工作,但结果是页面即时被加载到DIV发布,而不是URL我张贴到。

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!

推荐答案

如果在结果仅仅是HTML,那么你会说

If the "result" is just HTML, then you'd say

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

如果你想让它严格处理以纯文本:

If you want it treated strictly as plain text:

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