Alert based on if condition error
<p>I am trying to fire an alert based on wether a flag is set or not. The first time the page is loaded, the alert works fine. If I then alert data after success, then when I close the dialog the old data is still there. So instead of seeing no data, I still see the old data. The idea, is that if user closes the dialog without doing anything, then the else statement is triggered. I would be grateful if someone could help with this. many thanks</p>

<pre><code>var box;
var status;
var size;
var flag;


beforeclose: function (event, ui) {
                if(flag==1){
                jAlert("You have successfully editted\n\rBox: "+box+"\n\r"+
                           "Status: "+status+"\n\r"+
                           "Size: "+size+"\n\r", 'Box addittion successfull');

                }
                else{
                    alert("no data");
                }$("#f2").html("");
            }

success: function (data) {

                    flag = 1;
                    $("#EB_edit").get(0).reset();
                    $('#f2').html(data);
                    //$("#form").dialog('close');
                    $("#flex1").flexReload();

                }
</code></pre>
