通过调用返回参数的本地函数来构建Ajax Data部分
16lz
2021-01-22
I am having trouble figuring this simple thing out. Sorry I have tried all combinations of this and I cannot get it to work. Here is what I am trying to do
我无法解决这个简单的问题。对不起,我已经尝试了所有这些的组合,我无法让它工作。这是我想要做的
I have a javascrip function
我有一个javascrip功能
function getSelectedSearchCriteria() {
var data = {};
data.projname = "Test Project";
return data;
}
my Ajax function is called as
我的Ajax函数被称为
$.ajax({
url: "/Position/PositionList",
type: "POST",
dataType: "json",
data:getSelectedSearchCriteria
}
my controller method is defined as
我的控制器方法定义为
public ViewResult PositionList(string projname)
{
..
}
However the projname parameter is always a null. Any help appreciated
但是projname参数始终为null。任何帮助赞赏
Thanks
1 个解决方案
#1
0
Are you sure your javascript function is being invoked? The sample code you provide is missing a () after getSelectedSearchCriteria
你确定你的javascript函数被调用了吗?您提供的示例代码在getSelectedSearchCriteria之后缺少a()
data:getSelectedSearchCriteria
to
data:getSelectedSearchCriteria()
更多相关文章
- Jquery ajax回调函数不执行
- JQUERY组装对象并调用自身函数改变自己的属性
- Angular ng-show不会根据函数返回值显示/隐藏
- 未捕获的ReferenceError:函数未定义,它标记
- 我怎么能用javascript编写这个简短的函数?
- 你能告诉为什么javascript函数没有在profile.php的提交按钮中执
- JQuery函数不能用于初始触发器
- HTML+jQuery图片上传示例
- 如何让这段插入的innerHTML 里动态赋予的函数跑起来!