EDIT: I recently learned that this problem is actually two separate issues: 1) Using a script to close parent elements at the necessary junctures, and 2) Ensuring that the necessary functions were all called and completed in the correct sequence. I figured out two methods for closing the parent elements which I've included below. The 2nd issue is addressed here: Calling jQuery function in php (or modifying javascript so php runs the remaining code)
Original Question
I have 2 functions which I need to call once a form is validated and submitted, however I've been unsuccessful at inserting these functions into my script without preventing another function from being completed (either in the javascript or the php).
How can I integrate these functions to close parent items (an iframe and a notification to new users) into the script and/or call them from php after the form is validated and submitted?
New functions:
parent.close_field('notice');
parent.$.fancybox.close();
Existing Javascript
var $custInfo = $("#customer_info");
$(document).ready(function () {
var validator = $custInfo.validate({
rules: {.. },
messages: {..},
errorLabelContainer: "#messageBox",
submitHandler: function () {
$custInfo.ajaxSubmit({
});
}
});
$custInfo.find("input[name=gender]").change(function () {
if ($(this).val() == "male") {
$custInfo.submit();
}
});
});
I'm using Fancybox2. I've also tried other methods which require adding attributes to the form tag, however those circumvent the script entirely.