Когда JavaScript создает экземпляр службы WCF для конкретной машины, он выдает эту ошибку JavaScript. Однако служба WCF работает для других машин в другой сети. Я думаю, что порт заблокирован, но это догадка. Если у вас есть какие-либо идеи, пожалуйста, подайте их.
Ошибка JavaScript:
Сообщение: «LIMS.UI.Web.WCFServices.Accessioning» является нулевым или не является объектом
Сбой JavaScript в этой строке:
var service = new LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService ();
Вот фрагмент моего кода:
...
PreAccessioningLoad: function(sender) {
if (this.Elements.TxtSampleId.value != "") {
**var service = new LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService();**
jQuery(this.Elements.ImageAjaxSpinner).css("visibility", "visible");
service.PreAccessioningLoad(this.Elements.TxtSampleId.value, Function.createDelegate(this, this.PreAccessioningLoadSuccess), Function.createDelegate(this, this.PreAccessioningLoadError));
}
return false; //prevent page postback
},
PreAccessioningLoadSuccess: function(quickDataEntryObject) {
var val = jQuery(this.Elements.TxtSampleId).val().replace(/^\s\s*/, "").replace(/\s\s*$/, ""); // trim spaces
var intRegex = /^\d{1,10}$/;
if (!intRegex.test(val)) {
jQuery(this.Elements.SampleIdAjaxValidate).html("<span style='color:red'>Sample Id must contain between 1 and 10 digits</span>");
jQuery(this.Elements.ImageAjaxSpinner).css("visibility", "hidden");
jQuery(this.Elements.TxtSampleId).focus(); // triggers unwanted blur event
return false;
}
else {
jQuery(this.Elements.SampleIdAjaxValidate).html(""); // clear AJAX validation
}
if (quickDataEntryObject.Success == true) {
// set the hidden field to true so that we know to call the dbo.procPreAccessioningSave stored procedure
// this will be checked on a full page postback when they click Save Test and Sample
jQuery(this.Elements.HiddenContainsPreAccessioningData).val("true");
this._internalClientId = quickDataEntryObject.ClientId;
jQuery(this.Elements.TxtClientId).val(quickDataEntryObject.ClientIdentifyingNumber);
jQuery(this.Elements.DDLClientName).val(quickDataEntryObject.ClientIdentifyingNumber);
var thisTemp = this;
jQuery(thisTemp.Elements.DDLTest).children("option").each(function() {
jQuery(this).remove();
});
jQuery.each(quickDataEntryObject.TestPricingOptionsList, function(i) {
var key = quickDataEntryObject.TestPricingOptionsList[i].Key
var val = quickDataEntryObject.TestPricingOptionsList[i].Value
jQuery(thisTemp.Elements.DDLTest).append(jQuery("<option></option>").val(key).text(val));
});
jQuery(this.Elements.DDLTest).val(quickDataEntryObject.TestPricingOptionId);
//jQuery(this.Elements.ClientNameLabel).html("<b>Client: </b> [" + quickDataEntryObject.ClientIdentifyingNumber + "] " + quickDataEntryObject.ClientName);
//jQuery(this.Elements.TestLabel).html(" <b>Test Requested: </b> [" + quickDataEntryObject.TestPricingOptionId + "] " + quickDataEntryObject.TestPricingOptionName);
//jQuery(this.Elements.TestLabel).html("<b>Test Requested: </b> " + quickDataEntryObject.TestPricingOptionName);
//jQuery(this.Elements.DDLClientName).css("visibility", "hidden");
//jQuery(this.Elements.DDLTest).css("visibility", "hidden");
//jQuery(this.Elements.ClientIdLabelDiv).css("visibility", "hidden");
//jQuery(this.Elements.ClientIdDiv).css("visibility", "hidden");
//jQuery(this.Elements.TestIdDiv).css("visibility", "hidden");
//jQuery(this.Elements.ClientNameLabelDiv).css("visibility", "hidden");
//jQuery(this.Elements.TestLabelDiv).css("visibility", "hidden");
jQuery(this.Elements.LabelPreAccessioningData).html("<b><i>This Sample Id contains Pre-Accessioning Data</i></b>");
jQuery(this.Elements.TxtClientId).attr('readonly', 'true');
jQuery(this.Elements.DDLClientName).attr('disabled', 'disabled');
//jQuery("form:input:disabled[disabled='true']").css("color", "#ff0000");
}
else {
jQuery(this.Elements.HiddenContainsPreAccessioningData).val("false");
//jQuery(this.Elements.DDLClientName).css("visibility", "hidden");
//jQuery(this.Elements.DDLTest).css("visibility", "hidden");
jQuery(this.Elements.ClientNameLabel).html("");
jQuery(this.Elements.TestLabel).html("");
//jQuery(this.Elements.DDLClientName).css("visibility", "visible");
//jQuery(this.Elements.DDLTest).css("visibility", "visible");
//jQuery(this.Elements.ClientIdLabelDiv).css("visibility", "visible");
//jQuery(this.Elements.ClientIdDiv).css("visibility", "visible");
//jQuery(this.Elements.TestIdDiv).css("visibility", "visible");
//jQuery(this.Elements.ClientNameLabelDiv).css("visibility", "visible");
//jQuery(this.Elements.TestLabelDiv).css("visibility", "visible");
jQuery(this.Elements.LabelPreAccessioningData).html("");
jQuery(this.Elements.TxtClientId).removeAttr('readonly');
jQuery(this.Elements.DDLClientName).removeAttr('disabled');
//var thisTemp = this;
//jQuery(thisTemp.Elements.DDLTest).children("option").each(function() {
// jQuery(this).remove();
//});
// Omega wants the client and default test to persist
//jQuery(this.Elements.TxtClientId).val("");
//jQuery(this.Elements.DDLClientName).val(0);
// ideally we should get the default "Test Requested" here... call another AJAX query and select the default test or store the default in the object
}
//jQuery(this.Elements.TxtLAN).focus();
jQuery(this.Elements.ImageAjaxSpinner).css("visibility", "hidden");
return false;
},
PreAccessioningLoadError: function(sender) {
jQuery(this.Elements.ImageAjaxSpinner).css("visibility", "hidden");
alert("error"); // need to develop an error service for error handling and log the error to the log table!
return false;
},
...