I've read several posts and questions yet all seem to make things more confusing than help. I am doing what seems pretty simple.
I have a button on basically a login form...
$("#beginButton").click(function () {
if (validateStep(0) != false)
goWizard(1);
});
that when clicked validates that three text fields are not empty, then passes the values to an API that "logs in" the user and returns a dataset with details about them.
function validateStep(step) {
var isValid = false;
$("#alertsPanel").html("").fadeOut();
switch (step) {
case 0:
if ($.trim($("#login_LastName").val()).length == 0 || $.trim($("#login_BarNumber").val()).length == 0 || $.trim($("#login_BirthYear").val()).length == 0) {
$("#alertsPanel").html("<strong>Error:</strong> All values are required.").fadeIn();
return false;
}
else {
$.ajax({
url: "/api/User/authenticateByLNameBYearBarNum",
//async: false,
cache: false,
data: {
lastName: $.trim($("#login_LastName").val()),
barNumber: $.trim($("#login_BarNumber").val()),
birthYear: $.trim($("#login_BirthYear").val())
},
dataType: "json",
error: function (response) {
$("#alertsPanel").html("<strong>Error:</strong> Member information not found.").fadeIn();
return false;
},
success: function (data) {
return true;
}
});
}
break;
}
return isValid;
}
The first two checks work fine, I can validate the inputs are not empty and I can handle if the person is not found/returned by the API call. Where I am having the same issue as many others... I cannot correctly return the data to the calling function when the person is found. I get an object but it does not seem to contain the person details. I see the API does return the appropriate JSON.