I have a form to save/edit users and passwords into a database. During some tests I discovered that when the user or password text contains the char "<" the ajax call fails with error 500. I googled a lot but I didn't find anything useful to solve the problem. To be honest I'm not very skilled in jQuery and Ajax programming.
This is my ajax code, I use ASP.NET MVC5 and JQuery 3.3.1
var mydata = $("#FormItem").serialize();
$.ajax({
dataType: "text",
type: "POST",
url: '@Url.Action("SaveUsPwdInDB", "Computer")',
data: mydata,
success: function (result) {
var jobj = JSON.parse(result);
if (jobj.isValid == false) {
alert("Save Failed: \n\n" + jobj.jserror);
} else {
alert("Save Successful !");
}
},
error: function (result) {
fnPopupErrors(result);
}
});
I tried to change serialization type using .serializeArray() and also dataType from text to Json, but I got always the same 500 error. What I noticed is that when the code reaches the data:mydata row it throws the error, never reaches the execution of code in "SaveUsPwdInDB".
Any idea?