-1

I am using JQuery to submit a form without reloading the page, I have my code below and a screenshot of my error. Please tell me what I am doing wrong?

Code:

<script>
    $(document).ready(function() {

        $('form').submit(function (event) {
            event.preventDefault();
      var username = $("#username").val();
      var email = $("#email").val();
      var password = $("#password").val();
      var cpassword = $("#cpassword").val();
      var register = $("#register").val();
            $(".form-message").load("inc/register.php", {
                username: username,
        email: email,
        password: password,
        cpassword: cpassword,
                submit: register
            });
        });

    });
</script>

Screenshot: http://prntscr.com/im6oz6

Thanks for the help, Ethan!

Ethan
  • 67
  • 1
  • 9
  • can you show your jquery script link? – Badiparmagi Mar 03 '18 at 06:45
  • Possible duplicate of [What are the differences between normal and slim package of jquery?](https://stackoverflow.com/questions/35424053/what-are-the-differences-between-normal-and-slim-package-of-jquery) – Marco Mar 03 '18 at 06:47
  • 1
    Possible duplicate of [jquery ajax load not a function](https://stackoverflow.com/questions/46003790/jquery-ajax-load-not-a-function) – Badiparmagi Mar 03 '18 at 06:52

2 Answers2

0

You can use following post function

$.post('url',{params},function(res, err){
 /*your code here*/

});
0

You are using jQuery slim (screenshot) which does not include any AJAX functionality.(source)

Use jQuery instead.

Marco
  • 7,007
  • 2
  • 19
  • 49