I have TestingController. I would like to call method controller using jQuery for the button called CheckmoveSensor, and call method controller for MoveSensor for link called move using jQuery.
Try to call a method controller using JQuery but it’s not working but I would like to make JQuery working for call method controller CheckSensorMove and MoveSensor.
function checkSensorMove(e) {
e.preventDefault();
let sensorID = $(this).data("id");
$('#SensorMove').val(sensorID);
}
$.get('/Network/CheckSensorMove/' + $('#SensorMove').val(), function (data) {
eval(data);
if (data == "Success") {
}
else {
alert(data);
}
});
function MoveSensor(e) {
e.preventDefault();
let sensorID = $(this).data("id");
$('#SensorMove').val(sensorID);
}
$.get('/Network/CheckSensorMove/' + $('#SensorMove').val(), function (data) {
eval(data);
if (data == "Success") {
}
else {
alert(data);
}
});
[AuthorizeDefault]
public ActionResult CheckSensorMove(long id)
{
if (!Session.CustomerCan("Sensor_Can_Change_Network"))
return Content("alert('User not authorized to move sensor');");
try
{
return Content(string.Format("alert('SensorID: {0} not found.');", id));
}
catch (Exception ex)
{
return Content(string.Format("alert('SensorID: {0} could not be transfered to new network');", id));
}
}
[AuthorizeDefault]
public ActionResult MoveSensor(long id, long sensorID)
{
return Content("Success");
}
public static bool TryMoveSensor(long id, long sensorID)
{
return false;
}