views:

52

answers:

1

Hello,

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);
    }
});

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!

+2  A: 

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);
Pointy
I have actually tried using html() - this doesn't result in anything being displayed. Correct me if I'm wrong, but this should load the page that I'm posting to after the data has been posted right?
mike
It turned out to be an issue on the backend. Thanks though!
mike