我在我的 asp.net 网站中使用 jquery。它在我的本地系统中运行良好。但是当我在服务器上发布它时它不起作用。我的jQuery代码如下,
$("#<%=btnSubmit.ClientID %>").click(function (ev) {
ev.preventDefault();
$(this).attr("disabled", true);
if ($("#<%=ddlLetterType.ClientID %>").val() == "-1") {
alert("Please select a letter.");
$("#<%=ddlLetterType.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=ddlLetterType.ClientID %>").val() == "1") {
if ($("#<%=ddlEmbassyCountry.ClientID %>").val() == "-1") {
alert("Please select an Embassy Country.");
$("#<%=ddlEmbassyCountry.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=ddlTravelCountry.ClientID %>").val() == "-1") {
alert("Please select a Travel Country.");
$("#<%=ddlTravelCountry.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=txtEmbassyAddress.ClientID %>").val() == "") {
alert("Please enter embassy address.");
$("#<%=txtEmbassyAddress.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=txtPassportNo.ClientID %>").val() == "") {
alert("Please enter passport no.");
$("#<%=txtPassportNo.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=txtPlaceOfMeeting.ClientID %>").val() == "") {
alert("Please enter place of meeting.");
$("#<%=txtPlaceOfMeeting.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=txtStartDate.ClientID %>").val() == "") {
alert("Please enter start date.");
$("#<%=txtStartDate.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else if ($("#<%=txtEndDate.ClientID %>").val() == "") {
alert("Please enter end date.");
$("#<%=txtEndDate.ClientID %>").focus();
$("#<%=btnSubmit.ClientID %>").attr("disabled", false);
return false;
} else {
var parameter = {
request_no: $("#<%=lblRequestNo.ClientID %>").text(),
initiator_user_id: $("#<%=hInitiatorUserId.ClientID %>").val(),
initiatingDate: $("#<%=lblRequestdate.ClientID %>").text(),
embassy_country_id: $("#<%=ddlEmbassyCountry.ClientID %>").val(),
embassy_address: $("#<%=txtEmbassyAddress.ClientID %>").val(),
nationality: $("#<%=lblNationality.ClientID %>").text(),
passport_no: $("#<%=txtPassportNo.ClientID %>").val(),
company: $("#<%=lblCompanyName.ClientID %>").text(),
designation: $("#<%=lblDesignation.ClientID %>").text(),
joining_date: $("#<%=lblJoiningDate.ClientID %>").text(),
travel_country_id: $("#<%=ddlTravelCountry.ClientID %>").val(),
place_of_meeting: $("#<%=txtPlaceOfMeeting.ClientID %>").val(),
travel_start_date: $("#<%=txtStartDate.ClientID %>").val(),
travel_end_date: $("#<%=txtEndDate.ClientID %>").val(),
letter_filename: $("#<%=lblRequestNo.ClientID %>").text() + "_business_letter",
status: '2',
hr_letter_type_id: $("#<%=ddlLetterType.ClientID %>").val()
};
$.ajax({
type: "POST",
url: "<%=ResolveUrl("~/HRLetterService.asmx") %>/RegisterHRLetterBusinessData",
data: JSON.stringify(parameter),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
__doPostBack('<%=btnSubmit.ClientID.Replace("_", "$") %>', '');
},
error: function (msg) {
alert("Error in saving the request. Please contact your administrator by sending the screen shot to unify.admin@unilever.com");
$(this).attr("disabled", false);
return false;
}
});
}
}
.
.
.
.
我没有发布所有代码,因为代码很好并且没有错误。但唯一的问题是 if 语句。if 和 else if 语句被执行,但 else 部分没有被执行。可能是什么问题?请你帮助我好吗?提前致谢。