views:

48

answers:

0

Hi, I'm trying to create a window which pops up (using the jqModal plugin) only on the first time that a used clicks on a certain box.

var allow_popup = 1;

jQuery('.popup_header').click(function() {
        alert(allow_popup);
        if (allow_popup == 1)
        {
            jQuery('#dialog').jqm();   
        }
    });    

The popup contains a form which should set the variable 'allow_popups' to 0 when submitted:

jQuery(".ajax_submit").click(function() {
        var submit = 1;
        var name   = jQuery("input#nos_name").val(); 
        var email  = jQuery("input#nos_email").val(); 
        var data   = 'name='+ name + '&email=' + email +'&nos_help_form_submit=1';

        jQuery.ajax({
            type: "POST",
            url: "myurl",
            data: data,
            success: function() {  
                allow_popup = 0;
                jQuery('#dialog').jqmHide();
            }
      });
      return false;  
    });

I can see from the alert that the value of allow_popups is getting set to 0. However, the popup window is always displayed regardless.

Can anyone see what I have done wrong here?

Any advice appreciated.

Thanks.