Here is my code:
<form action='insert.php' method='post' id='myform' >
<input type='hidden' name='tmdb_id'/>
<button id='insert'>Insert</button>
<p id='result'></p>
<script src='insert.js'></script>
</form>
<form action='insert.php' method='post' id='myform' >
<input type='hidden' name='tmdb_id'/>
<button id='insert'>Insert</button>
<p id='result'></p>
<script src='insert.js'></script>
</form>
<form action='insert.php' method='post' id='myform' >
<input type='hidden' name='tmdb_id'/>
<button id='insert'>Insert</button>
<p id='result'></p>
<script src='insert.js'></script>
</form>
Here is: insert.js
$('#myform').submit(function(){
return false;
});
$('#insert').click(function(){
$.post(
$('#myform').attr('action'),
$('#myform :input').serializeArray(),
function(result){
$('#result').html(result);
}
);
});
The Problem:
Only the code inside first <form></form>
tag works. If i click on submit
button of other<form></form>
tags, then I get re-directed to insert.php
file.
What is the problem? If it is related to same id thing, then I would not like to add different id
's. for each new form