我使用jQuery與驗證插件,當我提交表單:JavaScript錯誤說:「確認不是一個函數」
$('.frmProject:visible').validate({
errorContainer: ".site_details:visible .messageBox1",
errorLabelContainer: ".site_details:visible .messageBox1 span.messagehere",
invalidHandler: function(form, validator) {
},
rules: {
site_id: {
required: true,
}
},
messages: {
site_id: "Project has no assigned site information. Click the marker on the map at left to specify the site where this project took place."
},
submitHandler: function(data) {
SaveProject();
}
});
在submitHandler,
function SaveProject(){
//... load variables with input contents
$.ajax({
url: 'ajax/save_project.php',
dataType: 'json',
data: 'id='+id+'&title='+title+'&project='+project+'§or='+sector+'&volunteer='+volunteer+'&lat='+lat+'&lng='+lng+'&name='+name+'&mun='+mun+'&prov='+prov,
success: function(data) {
//... load 'messages' object with stuff
$.each(messages, function(key, value) {
if (confirm(key)){
console.log(item);
}
});
}
});
}
當我提交驗證過的表單,並在每個循環內部進行確認,我收到錯誤消息:「確認不是函數」。
如何向用戶顯示消息以進行確認?
編輯:
當我鍵入 「確認」 到控制檯我得到這個:
在DOM檢查顯示:
窗口>確認() 沒有屬性可顯示此對象。
在腳本檢查帶我去一個地方jQuery的1.6.2.min.js
你想要做一個window.confirm(鍵)?確認在哪裏定義? – sissonb
我猜想1)某些東西改變了'window.confirm'或者2)有一個叫做'confirm'的變量......它不會傷害看到'confirm'的值是什麼。 – 2011-11-09 03:08:28
@pst:這是如何完成的? – Keyslinger