开发者

How to use $.get method in asp.net mvc

开发者 https://www.devze.com 2023-03-26 01:59 出处:网络
I have this code in m开发者_如何学编程y view to hit one ActionResult ClearFilters = function () {

I have this code in m开发者_如何学编程y view to hit one ActionResult

 ClearFilters = function () {
        $.get("/Mandate/Index/1");
        window.location.href = '<%=Request.Url.Scheme + "://" + Request.Url.Authority + Request.Url.AbsolutePath%>';
    }

My controller Method

Public ActionResult Index(int? id)
{
     //some code
}

with this Code I am able to hit Index Action Result but I am not getting int id value 1?

is that something I am doing wrong here?

Thanks


Try this. See if you get the id value, keeping all other code same.

$.get("/Mandate/Index", { id=1 }, success: function(){
   window.location.href = '<%=Request.Url.Scheme + "://" + Request.Url.Authority + Request.Url.AbsolutePath%>';   
});
0

精彩评论

暂无评论...
验证码 换一张
取 消