parent link:
<a href="feedback.php" id="feed">Provide your feedback here</a>
jQuery code to initiate fancybox is...
$("#feed").fancybox();
codes in feedback.php...
<html>
<head>
<script language="javascript">
$(document).ready(function(){
$("#feed_submit").click(function(){
//Name is alerted
alert($("#name").val());
//code to close fancy box(Not working)
$.fancybox.close();
});
});
</script>
</head>
<body>
<form method="post" name="feedback" id="feedback" action="">
<div>
<label>name</label>
<input type="text" name="name" id="name"/>
</div>
<div>
<label>feedback</label>
<input type="text" name="content" id="content"/>
</div>
<div><input type="button" name="feed_submit" id="submit" value="submit"></div>
</form>
</body>
</html>
Once submit button is clicked i need to close fancy box in this page itself with jquery
i have tried using
$.fancybox.close();
parent.$.fancybox.close();
But this doesn't work for me. If there is any option to close inside this ajax form please let me know.
on('click', function() { $. fancybox(); }); });
The following code should work, and has worked for many people
parent.$.fn.fancybox.close();
However, I have also seen, for instance in this question, jQuery being run in noConflict mode, unbeknownst to the user. If this is the case for you, you'd have to modify your script to
parent.jQuery.fn.fancybox.close();
If none of those work, please use a tool like Firebug for Firefox, or the developer console for Chrome, to see if there is an error message, and report back to us what it is.
Try
window.parent.$.fancybox.close();
assuming that $.fancybox.close();
works in the parent window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With