A small question that will certainly seem simple (im new).
I developed a project in Asp.net MVC with ajax / jquery. I then published my project on my local web server (via IIS10). I have some routes that have become untraceable ... However, I noticed via the web debugger that my parameters are sometimes passed differently.
Would you have an idea to fix that?
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.");
}
});
}));
}
This is the route seen in the debugger:
http://localhost/User/EditDelete/2?id=2
Thank you in advance!
Remove the data: { id: id }
part from the ajax settings;
for a GET
request, it causes the id
to be appended to the url as querystring.
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.");
}
});
}));
}