Click here to Skip to main content
14,877,782 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

The code below stop working all of a sudden and I can't figure out why. My HTML and Jquery are below. Any help would be apperciated.

I forgot to mention that the callback function with the return value is false because I am disabling the html form submit so I can take over with Jquery. Eventually, I would like to do an asycrounous form submit. However, I am unable to get this test script working. Any help would be apperciated.

<!DOCTYPE html>
  <meta charset="UTF-8">
  <script src="jquery3_2_1.js" type="text/javascript"></script>
<form class="ajax" method="post" action="UpdateCart.php">
<input type="hidden" name="Item" value="Chicken">
<input type="hidden" name="Price" value="2.99">
<input type="hidden" name="Qty" value="5">
<button type="submit">ADD TO CART</button>
  <script src="Test2.js" type="text/javascript"></script>

$("form .ajax").submit(function(){

return false;

What I have tried:

I tried .on('submit', function(){...}); but it still didn't work
Updated 5-Dec-17 22:33pm

1 solution

Zoom in here:
$("form .ajax")
Get rid of the space between them. The space conveys parent child relationship, i.e. look for "class=ajax" inside form.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900