Asp.Net / Ajax -> 在本地 IIS Web 服务器上的不同路由
Asp.Net / Ajax -> different routes when on a local IIS web server
一个看似简单的小问题(我是新手)。
我使用 ajax / jquery 在 Asp.net MVC 中开发了一个项目。
然后,我在本地 Web 服务器上发布了我的项目(通过 IIS10)。
我有一些无法追踪的路由......但是,我通过网络调试器注意到我的参数有时会以不同的方式传递。
你有解决办法吗?
function GetEdit() {
$("#UsersDatatables").on('click', '.edit', (function () {
var id = this.id;
$('#myModalLabel').text("Edit User");
$.ajax({
type: "GET",
url: "/User/EditDelete/" + id,
datatype: "json",
data: { id: id },
success: function (data) {
$("#USE_Id").val(data['USE_Id'])
$("#FirstName").val(data['USE_FirstName']);
$("#LastName").val(data['USE_LastName']);
if (data['USE_Gender'] == '0')
$("#Female").prop("checked", true);
else
$("#Male").prop("checked", true);
$("#Gender").val(data['USE_Gender']);
$("#Country").val(data['USE_CountryID']);
$("#Email").val(data['USE_EmailAddress']);
$("#PhoneNumber").val(data['USE_PhoneNumber']);
$("#GroupDrop").val("");
$('#myModal').modal('show');
},
error: function (error) {
toastr.error("The user update could not be performed.");
}
});
}));
}
这是在调试器中看到的路由:
http://localhost/User/EditDelete/2?id=2
提前致谢!
从 ajax 设置中删除 data: { id: id }
部分;
对于 GET
请求,它会导致 id
作为查询字符串附加到 url。
function GetEdit() {
$("#UsersDatatables").on('click', '.edit', (function () {
var id = this.id;
$('#myModalLabel').text("Edit User");
$.ajax({
type: "GET",
url: "/User/EditDelete/" + id,
datatype: "json",
success: function (data) {
$("#USE_Id").val(data['USE_Id'])
$("#FirstName").val(data['USE_FirstName']);
$("#LastName").val(data['USE_LastName']);
if (data['USE_Gender'] == '0')
$("#Female").prop("checked", true);
else
$("#Male").prop("checked", true);
$("#Gender").val(data['USE_Gender']);
$("#Country").val(data['USE_CountryID']);
$("#Email").val(data['USE_EmailAddress']);
$("#PhoneNumber").val(data['USE_PhoneNumber']);
$("#GroupDrop").val("");
$('#myModal').modal('show');
},
error: function (error) {
toastr.error("The user update could not be performed.");
}
});
}));
}
一个看似简单的小问题(我是新手)。
我使用 ajax / jquery 在 Asp.net MVC 中开发了一个项目。 然后,我在本地 Web 服务器上发布了我的项目(通过 IIS10)。 我有一些无法追踪的路由......但是,我通过网络调试器注意到我的参数有时会以不同的方式传递。
你有解决办法吗?
function GetEdit() {
$("#UsersDatatables").on('click', '.edit', (function () {
var id = this.id;
$('#myModalLabel').text("Edit User");
$.ajax({
type: "GET",
url: "/User/EditDelete/" + id,
datatype: "json",
data: { id: id },
success: function (data) {
$("#USE_Id").val(data['USE_Id'])
$("#FirstName").val(data['USE_FirstName']);
$("#LastName").val(data['USE_LastName']);
if (data['USE_Gender'] == '0')
$("#Female").prop("checked", true);
else
$("#Male").prop("checked", true);
$("#Gender").val(data['USE_Gender']);
$("#Country").val(data['USE_CountryID']);
$("#Email").val(data['USE_EmailAddress']);
$("#PhoneNumber").val(data['USE_PhoneNumber']);
$("#GroupDrop").val("");
$('#myModal').modal('show');
},
error: function (error) {
toastr.error("The user update could not be performed.");
}
});
}));
}
这是在调试器中看到的路由:
http://localhost/User/EditDelete/2?id=2
提前致谢!
从 ajax 设置中删除 data: { id: id }
部分;
对于 GET
请求,它会导致 id
作为查询字符串附加到 url。
function GetEdit() {
$("#UsersDatatables").on('click', '.edit', (function () {
var id = this.id;
$('#myModalLabel').text("Edit User");
$.ajax({
type: "GET",
url: "/User/EditDelete/" + id,
datatype: "json",
success: function (data) {
$("#USE_Id").val(data['USE_Id'])
$("#FirstName").val(data['USE_FirstName']);
$("#LastName").val(data['USE_LastName']);
if (data['USE_Gender'] == '0')
$("#Female").prop("checked", true);
else
$("#Male").prop("checked", true);
$("#Gender").val(data['USE_Gender']);
$("#Country").val(data['USE_CountryID']);
$("#Email").val(data['USE_EmailAddress']);
$("#PhoneNumber").val(data['USE_PhoneNumber']);
$("#GroupDrop").val("");
$('#myModal').modal('show');
},
error: function (error) {
toastr.error("The user update could not be performed.");
}
});
}));
}