使用jQuery传递给conroller方法的参数 [英] Parameter to be passed to conroller method using jquery

查看:65
本文介绍了使用jQuery传递给conroller方法的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发MVC应用程序.我在控制器中有如下方法:

Hi,
I am working on MVC application.I have a method in controller as below:

public ActionResult LogOn(string viewAction)
        {
            if (string.IsNullOrEmpty(viewAction))
                return View();
            else
                return null;
        }



基于viewAction,我想执行一些操作,但是此viewAction从未初始化.我正在使用jQuery ajax传递参数,如下所示:



Based on the viewAction i want to perform some action but this viewAction never gets initialised.I am using jquery ajax to pass parameters as below:

function Navigate(action) {
    
    $.ajax({ url: customerIdURL, data: { viewAction: "action"} });
} 


但是问题是viewAction始终为null.请帮助我.


But the problem is that viewAction is always null..Please help me out.

推荐答案

.ajax({url:customerIdURL,data:{viewAction:" }}); }
.ajax({ url: customerIdURL, data: { viewAction: "action"} }); }


但是问题是viewAction始终为null.请帮助我.


But the problem is that viewAction is always null..Please help me out.


这里有一篇文章可以帮助您传递参数:

在ASP.NET中使用jQuery AJAX从客户端调用服务器方法 [ ^ ]
Here is an article that will help you pass parameters:

Invoke Server Methods From Client Side Using jQuery AJAX in ASP.NET[^]


我怀疑上面的文章是否涵盖了MVC控制器的jQuery Ajax参数,请看一看: ^ ]
I doubt if the above article covers jQuery Ajax parameters to MVC controller, have a look at this one: Refreshing content of the table using AJAX in ASP.NET MVC (jQuery DataTables and ASP.NET MVC integration - Part III)[^]


这篇关于使用jQuery传递给conroller方法的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆