I've got a piece of JavaScript on a webpage that allows a user to scan in serial numbers and then it should send those to a webmethod where a database records it and a txtfile gets made.
It doesn't matter what's in the webmethod, because the code never runs. (Even removing the entire method and just make it change a bool to true as an example returns the same error). Here is the Js:
function sendingReady() {
saveSerialNumbers();
var employeeNr = document.getElementById("userCode").textContent;
var productNr = document.getElementById("productCode").textContent;
var cnt = {
employeeNumber: employeeNr,
productNumber: productNr
};
$.ajax({
type: "POST",
url: "WebServices.asmx/sendingReady",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
'cnt': cnt
}),
success: function() {
console.log("Success sendingReady")
},
error: function() {}
});
var succes = "succes";
localStorage.setItem("SuccesVerzenden", succes);
}
function saveSerialNumbers() {
var scannedserials = [];
var errorchoises = [];
var Table = document.getElementById("SerialListContainer");
var rowLength = Table.rows.length;
for (i = 0; i < rowLength; i++) {
var row = Table.rows[i];
var serialnumber = row.childNodes[0].textContent;
scannedserials.push(serialnumber);
var errorChoice = row.childNodes[1].childNodes[0].value;
errorchoises.push(errorChoice);
}
var cnt = {
serialNumber: scannedserials,
sendingErrorcode: errorchoises,
personalNumber: document.getElementById("userCode").textContent,
productNumber: document.getElementById("productCode").textContent
};
$.ajax({
type: "POST",
url: "WebServices.asmx/createSendingCeetisFile",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
'cnt': cnt
}),
success: function() {
console.log("Success saveSerialNumbers")
},
error: function() {}
});
}
To top function works, I get the "success SendingReady" message in my log. But the bottom function, called by the top one, does not. I've tried everything from sending the data as 4 separate instances, to changing the options in the Ajax call, to changing the recipient webmethod. This is said webmethod:
[System.Web.Services.WebMethod]
public void createSendingCeetisFile(SendingErrors cnt)
{
//unimportant code that doesn't ever run anyway;
}
with sendingErrors being:
public class SendingErrors
{
public string[] serialNumber { get; set; }
public string[] sendingErrorcode { get; set; }
public string[] dollies { get; set; }
public string personalNumber { get; set; }
public string productNumber { get; set; }
}
Dollies isn't being used yet. I'm using IIS and I haven't found any way to debug the server-side; All the IIS logs show is a generic '500' with no further detail.
I'm really hoping I'm missing something obvious, but after trawling through these forums and other sites looking for an answer for slightly over a day I'm kind of losing hope.