makerequest ajax,asp.net mvc - Make an AJAX request using $.ajax in MVC 4 - Stack Overflow

博主正尝试在MVC4 Razor视图中使用jQuery的$.ajax方法进行异步请求。他们成功地通过链接触发了数据返回,但在jQuery函数内部执行相同操作时遇到困难。代码示例显示了他们如何尝试调用HomeController的'test'方法并传递参数,但请求未按预期工作。
摘要由CSDN通过智能技术生成

I am trying to make an AJAX request using $.ajax in MVC 4 with Razor. I'm not sure how to implement it.

Using this video I was able to successfully make a link-driven call that returned data, but I can't seem to do the same thing from inside a jquery function. I can't seem to find any basic examples of how to do this.

This is what I am working with:

HomeController.cs

public string test(){

return "It works";

}

View.cshtml

function inventory(dealerID) {

$.ajax({

url: '@Url.Action("HomeController","test")',

data: {dealerID: dealerID},

type: 'POST',

success: function(data) {

process(data);

}

});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值