We have an application that's built using MVC/Knockout js. At the end of the form when the user goes to submit all of the data is turned into a json string and is sent through Jquery.ajax to our controller. Once it reaches there it will perform any validation returning the string "done" once the database commits are finished (if there are no issues). The ajax callback will set a variable with that done status and submit a final form containing that status, where if the status string isn't passed in as "done" error message will display which a handful of users have been seeing.
My question is does anyone know of any edge cases that could be causing the response not to return anything other than "done" (excluding validation errors or any exceptions which are logged by elmah). The validation step will throw an error that will return to elmah at any point where the data is invalid which hasn't happened yet (elmah has recorded other issues). For 99% of users there is no issue so I'm trying to figure out if there is some edge case I'm missing.
Below is my AJAX request, the data is built using the knockout plugin knockout.mapping then JSON.stringify. The one user we've heard back from is using internet explorer 11 (I'm unable to reproduce the error in my copy). Originally the timeout was 10 seconds, we've bumped it up to 30 which seemed to help (setting it to 1ms would return an empty string). One of the biggest issues with debugging the issue is that the data is anonymous so it's hard to tie an error back to any user.
$.ajax({
url: util.baseUrl('/Survey/Form'),
type: "POST",
data: dataStr,
contentType: "application/json; charset=utf-8",
timeout: 30000
})
.done(function (status) {
if (status === "done") {
self.gotoDonePage(status);
} else {
self.gotoDonePage(status);
}
})
.fail(function (err) {
self.gotoDonePage(status);
})
.always(function () {
layoutSetup.hideSpinner();
});
The data is anonymous, so we're only able to see where it came from but nothing else. The issue I'm having is the form submission that's done directly after this through the gotoDonePage method is passing a status other than "done". The validation is set up so that any errors at all, or invalid data will be caught by elmah which isn't happening. My theory is that the status that's being returned is an empty space or has extra spaces due to some issue. It could also be that the request is taking longer than 30 seconds to complete but it doesn't seem likely based on what I've experienced.
The gotoDonePage function is basically
self.gotoDonePage = function (status) {
var url = util.baseUrl('/Survey/Done');
var form = $('<form action="' + url + '" method="post">' +
'<input type="hidden" name="status" value="' + status + '" />' +
'<input type="hidden" name="surveyTypeCd" value="' + self.SchoolSurveyTypeCd() + '" />' +
'<input type="hidden" name="surveyName" value="' + self.SchoolSurveyNameTxt() + '" />' +
'<input type="hidden" name="schoolYear" value="' + self.SchoolYear() + '" />' +
'<input type="hidden" name="schoolName" value="' + $('#SchoolName').val() + '" />' +
'</form>');
$('body').append(form);
form.submit();
}
When the done page is returned there is just a simple razor if else to determine if it got the string of "done" and if not display the message.