JQuery Ajax Submit Twice?
Could someone point me in the right direction?
When I try to submit my jquery form the 2nd time it sends the data twice in one go. This is the same for 3rd (3x) and fourth+ (4x) and wonder whether the data/cache needs to be cleared each time I submit? Any guidance would be extremely grateful.
// Ajax Call (Uses JQuery Boxy Form) //
$(document).ready(function() {
$('#createlecture').click(function() {
var dialogbox = new Boxy('#dialog',{
title: 'Create a new lecture',
modal: true,
cache: false,
behaviours: function(c) {
c.find('#lectureform').submit(function() {
var lectureTitle = $('#lectureTitle').val();
var lectureDescription = $('#lectureDescription').val();
var courseID = $('#courseID').val();
var moduleID = $('#moduleID').val();
var dataString = 'lectureTitle=' + lectureTitle + '&lectureDescription=' + lectureDescription + '&courseID=' + courseID + '&moduleID=' + moduleID;
//alert(dataString);
if(courseID == 'None') {
Boxy.alert("Select course");
return false;
}
// Ajax Start
$.ajax({
type: "POST",
url: "MYPOSTURL",
data: dataString,
complete: function() {
$("section").load("MYHTMLFILE", {limit: 250}, function(){
dialogbox.hide();
});
return false;
}
});
});
}
}); // New Boxy Close
return false;
});
});