jQuery submit form without page reload

前端 未结 4 1659
野的像风
野的像风 2021-01-25 15:37

Ok, so I\'m trying to make a new log in form form my site using jquery and classic ASP. As of right now I have a containing div in my document thats set to hidden, then when the

4条回答
  •  被撕碎了的回忆
    2021-01-25 16:18

    Well you're certainly correct about the necessity to use (jQuery's) AJAX for this. Here's an example of what you should put in the form submit click handler.

    $.ajax({
      type: "POST",
      url: "dbProcessing.asp",
      data: $('#loginForm').serialize(),
      success: function(){
      // Insert any changes into the DOM that you like
      // msg will be whatever you print out in dbProcessing.asp
      // so set it to 'success' or something if the login was successful
      // and then do an if statement to see what === msg and insert
      // a message into the DOM or redirect based on that
      }
    });
    

    Edited for better practice (as per comment)

    Edit2: now I'm just getting careless

提交回复
热议问题