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()

更多相关文章

  1. Jquery ajax回调函数不执行
  2. JQUERY组装对象并调用自身函数改变自己的属性
  3. Angular ng-show不会根据函数返回值显示/隐藏
  4. 未捕获的ReferenceError:函数未定义,它标记
  5. 我怎么能用javascript编写这个简短的函数?
  6. 你能告诉为什么javascript函数没有在profile.php的提交按钮中执
  7. JQuery函数不能用于初始触发器
  8. HTML+jQuery图片上传示例
  9. 如何让这段插入的innerHTML 里动态赋予的函数跑起来!

随机推荐

  1. 又一家公司倒闭,阿里还是它的二股东
  2. vivo发年终奖了,几十个月,几十万,酸了
  3. 面试的时候,99%都是这7道题
  4. 面试官:我裤子拉链开了你怎么提醒我?
  5. 公司逼走员工的几个套路,你有中招吗?
  6. 欧阳娜娜入职阿里第一周,花式周报曝光
  7. 如何选择更适合你的 Linux 发行版?
  8. 百度账上躺着1300亿,今年员工将大幅涨薪,BA
  9. 老大甩给我 30G 文件,让小黑哥几天内全部
  10. 员工要离职,老板画饼,饼太大消化不了