在函数上调用AJAX错误标记的函数 [英] Call a function of an AJAX post wrong tag on the function
本文介绍了在函数上调用AJAX错误标记的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试调用AJAX帖子的功能。该功能无法调用我想到功能上的标签。
HomeController.cs
I am trying to call a function of an AJAX post. The function can not be called I think to the tag on the function.
HomeController.cs
[???]
public JsonResult somefunction(string value)
{
return Json(somelist2, JsonRequestBehavior.AllowGet);
}
Index.cshtml
Index.cshtml
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
...
$.post("Home/somefunction", json1, function (data,status) {
alert(status)
...
}
}, "json")
});
推荐答案
( function(){
...
(function () { ...
.post(Home / somefunction,json1,function(data,status){
alert(status)
...
}
},json)
});
.post("Home/somefunction", json1, function (data,status) { alert(status) ... } }, "json") });
当我按原样使用你的代码时,它不起作用。一旦我添加了两个分号,它就可以工作并调用一些函数控制器动作。警报(状态)之后和
When I used your code as is, it did not work. Once I add two semicolons it worked and invoked somefunction controller action. After alert(status) and after
之后
这篇关于在函数上调用AJAX错误标记的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文