MVC3调用Ajax的jQuery中对数据库存储的价值 [英] MVC3 call Ajax in Jquery for store value in database

查看:100
本文介绍了MVC3调用Ajax的jQuery中对数据库存储的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建MVC3应用
我的看法页面脚本code是 -

I am creating MVC3 Application My view Page script code is-

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        $('#btnClaimCheck').click(function () {
            var slvals = []
            $('input:checkbox[name=ChkCheckClaim]:checked').each(function () {
                if ($('#ClaimSelectStatus').val() == "XYZABCZ") {
                    alert("bikaner")

                    $.ajax({
                        url: '@Url.Action("CheckClaim")',
                        type: 'POST',
                       // data: { comment: $("#UpdatelabelName").val(prompt("Please Eenter Details","Rejected Without reason")) }
                        data: { comment: prompt("Please Enter Details", "Rejected Without reason")
                        }


                    });
                }
                else {
                    alert("other")

                }
            });

        });
    });                                                                                           
</script>

和我CONTROLER是 -

and my controler is -

   [HttpPost]
        public ActionResult CheckClaim(String comment)
        {
                return View();
           }

其工作和断点打在CONTROLER方法,但里面CONTROLER当我尝试调用从模型中的任何方法,那么就不能打到控制方法,并没有显示出任何错误。

its working and breakpoint hit on controler method but inside controler when i try to call any method from model then it can't hit the controller method and not show any error .

推荐答案

这是不是提示的好地方。结果
即使它正在 http://jsfiddle.net/j6PVm/1

This is not a good place for the prompt.
even though it is working http://jsfiddle.net/j6PVm/1

请用字符串替换它像

data: {comment : "mydata"}

这是刚刚看到Ajax是正常。

this is just to see that the ajax is functioning.

在一般的提示应该是 $。阿贾克斯范围之外。

in general the prompt should be outside of the $.ajax scope.

$('#btnClaimCheck')。点击(函数(){
VAR数据=提示(请输入详细信息,无理拒绝);

$('#btnClaimCheck').click(function () { var data = prompt("Please Enter Details", "Rejected Without reason");

$.ajax({
         url: '@Url.Action("CheckClaim")',
         type: 'POST',
         data: { comment: data}
      });
});

这篇关于MVC3调用Ajax的jQuery中对数据库存储的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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