I need to close an iFrame after the form within the iFrame was submitted, which I got with this function:
iFrame
$('#addCommentForm').submit(function(event) {
setTimeout(parent.closeIFrame('#popupAddComment{{ poiID }}-popup'), 500);
});
Main
function closeIFrame(iframe){
$(iframe).remove();
location.reload(true);
}
This works fine, even though my Chrome Browser (Version 44.0.2403.155 (64-bit)) won't wait the given time but fires the function instantly.
The problem I can't solve now is that the form will not be submitted to the PHP Symfony2 backend since I implemented the jQuery submit()
method.
I did a bit of research and found a possible solution
iFrame
$('#addCommentForm').submit(function(event) {
event.preventDefault();
this.submit();
setTimeout(parent.closeIFrame('#popupAddComment{{ poiID }}-popup'), 5000);
});
Sadly this won't work neither. Can somebody explain me what I'm doing wrong?