我在所有浏览器中都收到此错误“ jQuery SyntaxError: missing : after property id ”,我不知道如何解决。我已经通过 lint 运行了代码,我得到了同样的错误。代码中的违规行是:
$('#BA_boxform input:submit').on('click', function () {
由于我是 jquery/js 的新手,如果有人能告诉我哪里出错了,我将不胜感激。谢谢
jQuery代码
// function to connect to php and process form values
$(function(){
$("#BA_boxform").validate({
rules: {
name: { required: true },
lname: { required: true }
},
messages: {
name: { required: "* required" },
lname: { required: "* required" }
},
$('#BA_boxform input:submit').on('click', function () {
var formdata = $('#BA_boxform').serialize() + '&submit=' + $(this).val();
//alert(formdata);
$.ajax({
type: "POST",
url: "/sample/admin/requests/boxes/boxesadd.php",
data: formdata,
dataType: 'json',
success: function(msg){
if(typeof msg.boxerrortext !== "undefined" && msg.boxerrortext == "You need to input a box")
{
$("#BA_addbox").html(msg.boxerrortext);
}
else
{
$("#BA_addbox").html("You have successfully added box " + msg.box + " to the archive.");
}
//$("#confirm_department").hide();
/*
var $dialog = $('<div id="dialog"></div>')
.html('Your intake was successfully submitted and will be viewable in the reporting area.<br /><br />Thank you.');
$dialog.dialog({
autoOpen: true,
modal: true,
title: 'Box intake submission successfull',
width: 400,
height: 200,
draggable: false,
resizable: false,
buttons: {
Close: function() {
$( this ).dialog( "close" );
}
}
});
*/
//alert(msg);
//console.log(msg);
//$("#BA_addbox").html(msg.box);
//$("#formImage .col_1 li").show();
//$("#BA_boxform").get(0).reset();
//$("#boxaddform").hide();
}
});
return false;
});
});
});
// end php processing
// End function to submit box intake form