2010-04-26 28 views
0

我使用JQuery 1.3驗證並提交表單到PHP頁面,JSON編碼服務器響應以在原始表單頁面上顯示。jQuery形式堅持ajax指標,並不會提交

我試過提交表單沒有JQuery部分,一切似乎工作正常,但是當我添加JQuery它不提交併不斷顯示ajax指標。

這裏是我的代碼:


$(document).ready(function(){

var options = { target: '#messagebox',
url: 'updateregistration.php',
type:'POST', beforeSubmit: validatePassword, success: processJson, dataType: 'json'
}; $("form:not(.filter) :input:visible:enabled:first").focus(); $("#webmailForm").validate({

errorLabelContainer: "#messagebox", rules: { forename: "required", surname: "required", currentpassword: "required", directemail: { required: true, email: true }, directtelephone: "required" }, messages: { forename: { required: "Please enter your forename
" }, directemail: { required: "Please enter your direct e-mail address
", email: "Your e-mail address does not appear to be valid
(Example: [email protected])
" }, surname: { required: "Please enter your surname
" }, directtelephone: { required: "Please enter your direct telephone number
" }, currentpassword: { required: "Please enter your current password
" }

}

});

$('#webmailForm').submit(function() {

$('#ajaxindicator').show();

$(this).ajaxSubmit(options); 

    return false; 
}); 

});

function processJson(data) { $("#webmailForm").fadeOut("fast"); $("#messagebox").fadeIn("fast"); $("#messagebox").css({'background-image' : 'url(../images/messageboxbackgroundgreen.png)','border-color':'#009900','border-width':'1px','border-style':'solid'}); var forename=data.forename; var surname=data.surname; var directemail=data.directemail; var directphone=data.directphone; var dateofbirth=data.dateofbirth; var companyname=data.companyname; var fulladdress=data.fulladdress; var telephone=data.telephone; var fax=data.fax; var email=data.email; var website=data.website; var fsanumber=data.fsanumber; var membertype=data.membertype; var network=data.network;

$("#messagebox").html('<h3>Registration Update successful!</h3>' + '<p><strong>Member Type:</strong> ' + membertype + '<br>' + '<strong>Forename:</strong> ' + forename + '<br><strong>Surname:</strong> ' + surname + '<br><strong>Direct E-mail:</strong> ' + directemail + '<br><strong>Direct Phone:</strong> ' + directphone + '<br><strong>Date of Birth:</strong> ' + dateofbirth + '<br><strong>Company:</strong> ' + companyname + '<br><strong>Address:</strong> ' + fulladdress + '<br><strong>Telephone:</strong> ' + telephone + '<br><strong>Fax:</strong> ' + fax + '<br><strong>E-mail:</strong> ' + email + '<br><strong>Website:</strong> ' + website + '<br><strong>FSA Number:</strong> ' + fsanumber + '<br><strong>Network:</strong> ' + network + '</p>'); 

$('#ajaxindicator').hide();

}

function validatePassword(){ var clientpassword=$("#clientpassword").val(); var currentpassword=$("#currentpassword").val(); var currentpasswordmd5=hex_md5(currentpassword); if (currentpasswordmd5!=clientpassword){ $("#messagebox").html("You input the wrong current password, please try again."); $('#ajaxindicator').hide(); return false; } }

我有一個殘疾的文本框,一些隱藏的。這可能是問題嗎?

回答

0

試圖隱藏/對Ajax請求的狀態顯示進度條,請通過此代碼檢查:

jQuery(document).ajaxSend(function(){ 
    jQuery("#loading-mask").show(); 
    }); 

jQuery(document).ajaxComplete(function(){ 
    jQuery("#loading-mask").hide(); 
}); 

刪除$( '#ajaxindicator')顯示()。從您的代碼

+0

謝謝Chirag!我拿出$('#ajaxindicator')。show();從代碼,現在指標出現一秒鐘然後消失。事情是,形式仍然不會提交。 – 2010-04-26 15:21:39