I am having an issue with $.ajax while trying to post a form
Hi
so i have a forum within forum something like this
<form id="parent" method="post" action="sucess.php>
<form id="additionDriverForm">
<input type="submit" value="add sub" />
</form>
<input type="submit" value="add main" />
</form>
this is my jquery code
-
<script type="text/javascript">
/* attach a submit handler to the form */
$("#additionDriverForm").submit(function(event) {
/* stop form from submitting normally */
event.preventDefault();
/*clear result div*/
$("#additionlResult").html('');
/* get some values from elements on the page: */
var values = $(this).serialize();
/* Send the data using post and put the results in a div */
$.ajax({
url: "addDriver.php",
type: "post",
data: values,
success: function(data){
$('#additionlResult').removeClass().addClass((data.error === true) ? 'errorBox' : 'passBox').html(data.msg).fadeIn('fast');
if ($('#additionlResult').hasClass('passBox')) {
$('#additionlResult').fadeIn('fast');
window.setTimeout( $('#addDriverPanel').hide('fast'), 2000);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#response').removeClass().addClass('errorBox')
.html('<p>There was an<strong> ' + errorThrown +
'</strong> error due to a<strong> ' + textStatus +
'</strong> condition.</p>').fadeIn('fast');
},
complete: function(XMLHttpRequest, status) {
$('#additionDriverForm').reset();
}
});
});
</script>
The problem is when i submit the child forum the parent what get submitted. What can I do to submit the child forum only when the child submit button is clicked?
thanks