jQuery - stop form submission from changing page using ajax

user3327457

I am trying to submit a form without reloading the page. I have tried using this script with no success:

$('#formId').submit(function(e){
    $.ajax({
        type: "POST",
        url: 'serverSide.php',
        data: $('#formId').serialize(),
        success: function(data){
            alert(data);
        }
    });
    e.preventDefault();
});

Does anyone know what I am doing wrong?

bottens

Using return false will usually do the trick

$('#formId').submit(function(e){
    $.ajax({
      type: "POST",
      url: 'serverSide.php',
      data: $('#formId').serialize(),
      success: function(data){
        alert(data);
      }
    });
  e.preventDefault();
  return false;
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Having to refresh a page after form submission using jquery ajax

Don't reload page after form submission using ajax and jquery

Ajax form submission on a form created using jquery

Form submission using ajax and page view moderation after the submission

submitting form with jQuery/AJAX, cant stop page from refreshing on submit?

Submitting a form using jQuery and Ajax changing the action

How to validate a form's input from ajax page using jquery

stop form submission in ajax if validation failed

Form Submission not working second time after submiting using Jquery and Ajax

How to confirm a form submission with Bootbox using jQuery AJAX and JSON

jQuery ajax form submission to php not working with response from server

How to make Jquery to stop form submission

Delayed form submission using JQuery

Stop page from redirecting after submitting google form through AJAX

Ajax form submission with Jquery validation plugin is not working

jQuery - Loading form submission in DIV of parent page (?)

Using PHP form validation on jQuery form submission

Remove ajax from the form submission in PHPLucidFrame

INSERT failing on Form Submission from Page

Form submission through ajax and reply from servlet through JSON without page refresh

How to stop form submission?

Prevent double submission of form using jQuery

Auto form submission using jquery is not working

Form submission using Jquery: NULL is submitted

form submission using jquery.confirm

jQuery validation - something is preventing form from submission

Changing a form into Ajax or Jquery form -MVC

Create page redirects on form submission from specific checked radio buttons using javascript

JQuery form submission without page refresh not working due to JQuery conflict

TOP Ranking

HotTag

Archive