Код: Выделить всё
$('.imageLandscapeFloatLeft').on('click', function () {
var vIDString = this.getAttribute('id');
if (vIDString.indexOf("image_") >= 0) {
var vID = vIDString.substring(6);
if ($.isNumeric(vID)) {
jQuery.ajax({
url: '@Url.Action("ReturnSoftwareImage", "Business")',
type: 'POST',
data: { ImageID: vID },
success: function (response) {
if (typeof (response) == 'object') {
var vAlt = (response.alt);
var vLink = (response.link);
ModalInformation(vAlt, vLink);
}
else {
ModalError(response);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
ModalError(textStatus + " - " + errorThrown);
}
})
}
}
})
Код: Выделить всё
$('.imageLandscapeFloatLeft').on('click', function () {
var vIDString = this.getAttribute('id');
if (vIDString.indexOf("image_") >= 0) {
OpenImageModal("Business", "ReturnImage", "ReturnWebImage", vIDString, "6");
}
})
function OpenImageModal(ControllerName, ActionResultName, ActionData, IDString, IDLength) {
var vID = IDString.substring(IDLength);
if ($.isNumeric (vID)) {
alert(vID);
jQuery.ajax({
url: '@Url.Action()',
type: 'POST',
data: { ActionData: vID },
success: function (response) {
if (typeof (response) == 'object') {
var vAlt = (response.alt);
var vLink = (response.link);
ModalInformation(vAlt, vLink);
}
else {
ModalError(response);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
ModalError(textStatus + " - " + errorThrown);
}
})
}
}
Я пытаюсь найти способ передать переменные (в данном случае ControllerName и ActionResultName) в URL-адрес Ajax @Url.Action()
code> - но пока заключить его в кавычки и другие методы не удалось.
Подробнее здесь: https://stackoverflow.com/questions/790 ... sp-net-mvc
Мобильная версия