问题描述
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: '/demo1.asmx/HelloWorld',
data: "{}",
dataType: 'json',
success: function (r) {
alert('done');
},
error: function (r) {
alert(r.val());
}
});
我想调用HelloWorld方法,它不工作。 或如何在Jquery和C#中调用'HelloWorld'方法。 /> 请anybode帮助我。
I wan to call HelloWorld method, it is not working. or how to call 'HelloWorld' method in Jquery and C#. Please anybode help me.
推荐答案
.ajax({ type:'POST', contentType:'application / json; charset = utf-8', url:'/ dev1.asmx / HelloWorld', data:{}, dataType:'json',成功:函数(r){ alert('done'); },错误:function(r){ aler t(r.val()); } }); .ajax({ type: 'POST', contentType: 'application/json; charset=utf-8', url: '/demo1.asmx/HelloWorld', data: "{}", dataType: 'json', success: function (r) { alert('done'); }, error: function (r) { alert(r.val()); } });
我想调用HelloWorld方法,它不起作用。 或如何在Jquery和C#中调用'HelloWorld'方法。 请anybode帮助我。
I wan to call HelloWorld method, it is not working. or how to call 'HelloWorld' method in Jquery and C#. Please anybode help me.
语法看起来很好。如果它失败了,那么它给出了什么错误? 而不是: The syntax looks fine. If it's failed, then what error's it giving? Instead of:
alert(r.val());
尝试:
Try:
alert(r.statusText);
看看它给出的状态。如果它给出无运输状态,那么这是一个跨域发布问题,可以解决如下: