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:
Hi,

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>
<html>
<head>
  <meta charset="UTF-8">
  <script src="jquery3_2_1.js" type="text/javascript"></script>
</head>
<body>
<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>
</form>
  <script src="Test2.js" type="text/javascript"></script>
</body>
</html>


$(document).ready(function(){
$("form .ajax").submit(function(){
alert('Trigger');

return false;
  });
});


What I have tried:

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

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.
   
v2

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