Hello! I have tried for three days to solve my problem, please help.
I have a custom form, on the save button it calls the javascript function save_form(), my custom form works great as long at there is no AJAX return errors, but if AJAX returns an error, my custom form won’t close. It just stays on screen.
The line: scheduler.endLightbox(true, html(“my_form”));
works if it is just in the function, but as soon as i place it in the ajax call it stops working.
I just want to turn off the custom form using a command upon success message returned from the ajax call.
below is the entire function… (look for my comments in the code below)
function save_form() {
var ev = scheduler.getEvent(scheduler.getState().lightbox_id);
var event_id = ev.id;
var caldata = "ddlStage=" + $("#ddlStage").val() ; // I trimmed this for conciseness
$.ajax({
type: "POST",
async: "false",
url: "Calendar_Save_Appointment.aspx",
data: caldata,
success: function (msg) {
if (msg.length > 20) {
alert("There was a problem saving the data, could be just a server communication error, however, just in case check your data, then save again.");
return
}
if (msg.length > 0) {
scheduler.changeEventId(event_id, msg);
scheduler.getEvent(msg).text = eventText;
scheduler.updateEvent(msg);
clearformvals();
// THIS NEXT LINE IS NOT WORKING,
// I WAS HOPING IT WOULD CLOSE THE CUSTOM FORM
scheduler.endLightbox(true, html("my_form"));
alert("saved");
return
}
}
});
// IF I HAVE THIS LINE OUTSIDE THE AJAX, IT WORKS. I COMMENT OUT FOR NOW
// scheduler.endLightbox(true, html("my_form"));
}