Reputation: 6976
I am making a CMS for a website at the moment, and one of the features is that a the user can crop an image on the fly, they does this within a fancybox instance and all the details are possted to the controller via ajax, on successful cropping of the image, I am wanting to close the fancy box instance automatically, however I cannot seem to get the window to close, below is my code,
$("#crop").submit(function(e){
$.ajax({
type : "POST",
dataType: "json",
url : $(this).attr('action'),
data : "x="+$("#x").val()+"&y="+$("#y").val()+"&x2="+$("#x2").val()+"&y2="+$("#y2").val()+"&w="+$("#w").val()+"&h="+$("#h").val()+"&isAjax=1&crop_image=Crop",
success:function(json) {
if(json.message == "Image Cropped") {
$.fn.fancybox.close();
}
}
});
e.preventDefault();
});
Running this code works fine until $.fancybox.close()
where I get this error,
$.fn.fancybox.close is not a function
how can I close fancybox on a successful ajax request?
Upvotes: 1
Views: 1296