jquery model form
<pre><code>function checkname(o) {
    var o = $('#log').val();                
    $.ajax({
        url: 'check_name',
        type: 'POST',
        data: 'username=' + o,
        success: function(o){
            if(o == 1) {
                 return o;
            }
            else {
                 o.addClass( "ui-state-error" );
         updateTips( "not available" );
         return false; 
            }
        }
  });
}
</code></pre>

<p>this function related with form in model to check is available or no </p>

<pre><code>$( "#dialog-form" ).dialog({
     autoOpen: false,
     height: 600,
     width: 550,
     modal: true,
     buttons: {
    "save": function() {
        var bValid = true;
        allFields.removeClass( "ui-state-error" );

        bValid = bValid &amp;&amp; checkname ( name, "name");


        if ( bValid ) {
                $.ajax({
            type: 'POST',
            url: 'add_user',
            data: $('#myform :input').serialize(),

            success: function(i) {
                alert('sucess');
                            window.setTimeout(function(){location.reload()},500)

            }
        });
        $( this ).dialog( "close" );
    }
    },
    Cancel: function() {
    $( this ).dialog( "close" );
    }
   },
   close: function() {
     allFields.val( "" ).removeClass( "ui-state-error" );
   }
});
</code></pre>

<p>when i click save form wont save or wont close only in firebug return 1 </p>

<p>i want if name available form save</p>
