AJAX调用ASP.Net Server Side Web服务方法问题

时间:2011-07-25 13:35:14

标签: jquery

我试图让AJAX调用ASP.Net Server Side Web服务方法它不会给我错误或异常的问题

我正在尝试执行代码的和平,当用户单击按钮我希望它调用我的自定义服务并执行它然后将结果返回到另一个控件[网格视图]

代码是:

<script type = "text/javascript">
function myfunction() {
    $.ajax({
        type: "POST",
        url: "My method",
        data: Bind Data,
        dataType: "json",
        success: alert();,

    });
}

</script>

问题是它不起作用我尝试了火虫并且它没有调用方法

2 个答案:

答案 0 :(得分:3)

$.ajax({
        type: "POST",
        url: "/path/to/webservice",
        data: {data:data}, //not sure what Data Bind is?
        dataType: "json",        
        success:function(data){
            alert("success");
       },
        error:function(jxhr){
           alert(jxhr.responseText);
       }

    });

jquery ajax

这里也是一个有用的链接POSTing JSON Data to MVC Controllers

答案 1 :(得分:0)

好的问题不明白,如果你没有做出类似的事情,你需要在你的问题中更具体,你试图使用j查询对ASP.Net服务器端Web服务方法进行AJAX调用我有在我的博客中找到同样问题的相似帖子看看:

http://eslamsoliman.blogspot.com/2011/07/make-ajax-call-to-aspnet-server-side.html

我认为你的jquery代码在URL部分和成功部分中的问题如果有帮助就标记为已回答:)

相关问题