我在 View 中有一个部分 View ,我想使用ajax将参数从 View 传递到 Controller ,但是ajax的url始终具有父级的url:http://localhost/Project/Detail/项目/DeleteTM/?input=3,124
这是我的ajax代码:
$.ajax({
url: '/Project/DeleteTM/',
type: 'GET',
data: {input:input},
dataType: 'html',
success: function (result) {
if (result == 'true') {
UIkit.notify("Success",
{status: 'success', pos: 'top-center' });
setTimeout(function () {
location.reload(); }, 1000);
} else {
UIkit.notify("Fail",
{ status: 'danger', pos: 'top-center' }); } } });
我的父 View 有 url:http://localhost/Project/Detail
当ajax向服务器发送请求时,如何更改它的url!
最佳答案
试试这个:
$.ajax({
url: 'Url.Content("~/Project/DeleteTM")',
type: 'GET',
data: {input:input},
dataType: 'html',
success: function (result) {
if (result == 'true') {
UIkit.notify("Success",
{status: 'success', pos: 'top-center' });
setTimeout(function () {
location.reload(); }, 1000);
} else {
UIkit.notify("Fail",
{ status: 'danger', pos: 'top-center' }); } } });
关于javascript - Ajax - 从 subview 设置 ajax 的 url 不依赖于父 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37879335/