I try make ajax request to server with two parameters and get from server string:
JavaScript:
function getLetterOfResponsibilityNote(selectedCountryCode, selectedIntendedUseType) {
$.ajax({
type: "POST",
url: "/Admin/Applications/SelectLetterOfRespinsibilityNote",
cache: false,
data: { countryCode: selectedCountryCode, intendedUseType: selectedIntendedUseType },
success: function(response) {
if (response !== "") {
alert("1");
}
}
});
}
And mvc action:
[HttpPost]
public string SelectLetterOfRespinsibilityNote(string countryCode, string intendedUseType)
{
var countryDetails = new List<ContryLetterOfResponsibility>
{
new ContryLetterOfResponsibility
{
CountryCode = countryCode,
IntendedUseType = intendedUseType
}
};
string xml = XmlSerializerUtil(countryDetails);
var country = _countryService.GetLetterOfResponsibilityNotesByCountryCodeList(xml).FirstOrDefault();
if (country != null)
{
return country.LetterOfResponsibilityNote;
}
return string.Empty;
}
I get response object in javascript and verify its value. If its value not empty string, I get alert message. If server pass in JavaScript empty string, i get Document object in success action NOT EMPTY STRING. What is it?