One of the functionalities on my website involves making an AJAX call to retrieve a member's profile information for editing purposes. The code snippet responsible for this operation is shown below:
function loadProfileData() {
var request = $.ajax({
url: "../handlers/getprofile.ashx",
method: "POST"
});
request.done(function (msg) {
if (msg.Success == false) {
$('#spnProfileErr').html(msg.Status);
$('#toastProfileFail').toast('show');
}
else {
$('#lastname').val(msg.MemberProfile.LastName); // textbox
$('#firstname').val(msg.MemberProfile.FirstName); // textbox
$('#bestemail').val(msg.MemberProfile.BestContactEmail); // textbox
$('#agerange').val(msg.MemberProfile.AgeRange); // select control
$('#zipcode').val(msg.MemberProfile.ZIPCode); // textbox
}
});
request.fail(function (jqXHR, textStatus) {
$('#spnProfileErr').html('Unable to retrieve your existing profile at this time.');
$('#toastProfileFail').toast('show');
});
}
The AJAX call to fetch the data from the web service is successful and it returns a JSON string, as seen in the screenshot here: https://i.stack.imgur.com/LsG56.png
While I can access the 'Success' and 'Status' properties of the returned JSON object, I encounter difficulties accessing the individual profile properties within the MemberProfile attribute. Attempting to access something like msg.MemberProfile.LastName
results in an 'undefined' error.
What could be causing this issue with retrieving the specific member profile details?