I'm having problem submitting a HTML form using JavaScript & AJAX from a hyperlink (href) instead of the normal input type. My current code is as follows:
Javascript (executed just before body tag):
$(document).ready(function () {
//Chronicle Form 1
$('#fm_chronicledate').submit(function(event) {
var data = $('#fm_chronicledate').serialize() + 'cron=1' + '&chron_date=' + chron_date.val() + '&chron_time=' + chron_time.val();
$.ajax({
type: "GET",
url: "script.php",
data: data,
cache: false,
success: function(html) {
if(html == 1){
$('#chron_part1').fadeOut('slow');
} else alert('Error');
}
});
return false;
});
});
HTML:
<form id="fm_chronicledate" method="POST" action="#" >
<input type="text" class="website" name="chron_time" id="chron_time" />
<input type="text" class="website" name="chron_date" id="chron_date" />
<a href="#" class="chron_submit1" id="chron_submit1" onclick="fm_chronicledate.submit(); return false;">Submit</a>
</form>
Anyways for some reason it just does not execute the AJAX.
Any help would be much appreciated. Thank you.