MVC3调用Ajax的jQuery中对数据库存储的价值 [英] MVC3 call Ajax in Jquery for store value in database
问题描述
我创建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屋!