views:

32

answers:

1

I'm trying to post to a form using jQuery and read the results of the posted page. I have created a super simple example.

    $('#submit').click(
        function () {
            $.get('post.htm',
                {
                    demo : "true"
                },
                function (data) {
                    alert('data load: ' + data);
                },)
        });

the html page for post.html is just a simple html form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <title></title>
</head>
<body>
this is a post
</body>
</html>
A: 

There's a subtle syntax error in your jQuery code: the line after your success callback should be }); instead of },).

If you fix that, this alerts the entire contents of post.htm when you click #submit:

$(function(){
    $('#submit').click(function () {
        $.get('post.htm',
            {demo : 'true'}, 
            function (data) { alert('data load: ' + data); 
        });
    });
});
Jeff Sternal
well, that was easy
wcpro