Nov 30

One of the best jQuery plugins to display a popup modal window is fancybox

The usage is simple:

$(“.popup”).fancybox();
$.fancybox.resize();

and make sure your link has popup class. It will load the page pointed by your link href and resize as needed.

What if you display a form in the popup and want to reload it with an success message? Use this: $(‘#fancybox-content’).html(data); where data is the content you want to show in popup.

For example, using ajax to submit the form:

$.ajax({
url: ‘exemple.com’,
data: $(‘#form1′).serialize(),
type: ‘post’,
cache: false,
dataType: ‘html’,
success: function (data) {
$(‘#fancybox-content’).html(data);
$.fancybox.resize();
},
error:function (e,data) { alert(e); }
});

Comments are closed.

Powered By Wordpress - Theme Provided By Wordpress Theme - Credit Loan