0

I want to be able to get only the contents of a div instead of loading the full page.

My current js is:

    $(document).ready(function(){
    $("#myform").validate({
        debug: false,
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            name: "Please let us know who you are.",
            email: "A valid email will help us get in touch with you.",
        },
        submitHandler: function(form) {
            $.post('file.php', $("#myform").serialize(), function(data) {
                $('#results').html(data);
            });
        }
    });
});

It's loading the whole page when I submit the form, I want it to only load the contents of one div.

0

1 Answer 1

0

Refer the below links to find out how the DIV elements can be accessed using JavaScript:

Get content of a DIV using JavaScript

How can get the text of a div tag using only javascript (no jQuery)

):

1
  • Thanks for the link, I already saw those though. I'm looking for a way to edit what I already have.
    – Eddie
    Jan 21, 2013 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.