ASP.NET ajax不起作用
我不知道为什么这不起作用(无法调用SendValues方法)。没有出现错误。 有人能帮我吗?多谢各位 html页面包含以下内容:ASP.NET ajax不起作用,asp.net,jquery,Asp.net,Jquery,我不知道为什么这不起作用(无法调用SendValues方法)。没有出现错误。 有人能帮我吗?多谢各位 html页面包含以下内容: <script language="javascript" type="text/javascript"> $(function () { $("#Button1").click(function () { $.ajax({ type: "POST",
<script language="javascript" type="text/javascript">
$(function () {
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "WebForm1.aspx/SendValues",
data: { 'Code': '1026' },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (json) {
alert(json.d);
},
failure: function () {
alert("Sorry,there is a error!");
}
});
});
});
</script>
我通过将数据:{'Code':'1026'}更改为“data:{'Code':'1026'}”解决了这个问题。数据应指定为
data: '{ Code:["1026"]}'
“不工作”是什么意思?@Kirill Bestemyanov无法调用SendValues方法,您是否可以查看AJAX请求是否实际触发(使用Fiddler或其他web代理)?您是否看到函数正在执行(使用浏览器上的开发人员工具)?您是否在服务器上遇到异常-如果是,是什么?
data: '{ Code:["1026"]}'