我正在尝试进行此 AJAX 调用:
function Test(){
var results = new Array();
var emp1 = { "ID": "12", "Name": "Manas" };
results.push(emp1);
var emp2 = { "ID": "2", "Name": "Tester" };
results.push(emp2);
var postData = { empList: results };
$.ajax({
url: 'Sprachen/SaveEmpList',
data: JSON.stringify(postData),
type: 'POST',
contentType: 'application/json',
dataType: 'json',
beforeSend: function () {
},
success: function (result) {
alert(result);
},
complete: function () {
},
failure: function (jqXHR, textStatus, errorThrown) {
alert("Status: " + jqXHR.status + "; Error: " + jqXHR.responseText); // Display error message
}
});
}
我的控制器:
public static bool SaveEmpList(List<Employee> empList)
{
try
{
// Implement your logic to save EmpList in Database
}
catch (Exception ex)
{
// Log Error
return false;
}
return true;
}
这是我单击按钮调用Test()函数之前的基本URL
https://localhost:44306/Jobs/Sprachen?categoryId=handwerk&handler=UserId
我得到了一个404。
我如何创建URL,这样我就不会得到404了?
1条答案
按热度按时间eqqqjvef1#
这将起作用: