阿贾克斯(调用Web服务)与MVC [英] Ajax (calling web service) with MVC

查看:129
本文介绍了阿贾克斯(调用Web服务)与MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net MVC应用程序,我需要使用AJAX在此应用中,我需要添加一个ScriptManager和Web服务的路径添加服务refrences,然后调用来自标签的Web服务。 我有以下的code,并没有看到Web服务:

I have an asp.net mvc application and i need to to use ajax in this application , i need to add a scriptmanager and add a service refrences with the path of a web service and then call the web service from tag . I have the following code and it doesn't see the web service :

<form>
<input id="SubmitBtn" type="button" value="Sumbit" onclick="TestService(); return false;" />
   <asp:ScriptManager ID="ScriptManager1" runat="server">
    <Services>
        <asp:ServiceReference Path="~/MVCService.asmx" />
    </Services>
    </asp:ScriptManager> 
<script type="text/javascript" language="javascript">  
    function TestService()
    {
        alert('Welcome');
        var ret = MVCService.HelloWorld(OnCheckComplete,OnFailed,OnTimeOut);
    }
    function OnCheckComplete(arg)
    {
         alert(arg);
    }
    function OnFailed(arg)
    {
        alert(arg);
    }
    function OnTimeOut(arg)
    {
        alert(arg);
    }
     </script>
</form>

和它报告错误说:MVCService未定义 那么,如何解决这个问题? 我需要在MVC应用程序来解决这个问题,具体的配置? 我有加Ajax工具包的dll到我的应用程序refrences和问题依然存在。

And it reports an error say : MVCService is undefined so how can i solve this problem ? do i need specific configuration in the MVC application to solve this problem ? I have add ajax toolkit dll to my application refrences and the problem still exist

在此先感谢

推荐答案

感谢每一个我已经找到了soltuion为在folloiwng链接的问题: Ajax和ASP .NET MVC

Thanks every one i have found the soltuion for the problem at the folloiwng link : Ajax with asp.net mvc

下面的部分解决了我的问题:

The following part solved my problem:

<script type="text/javascript" src="../../Content/MicrosoftAjax.debug.js"></script>
<script type="text/javascript">   
function TestService() 
{  
   Sys.Net.WebServiceProxy.invoke("../../Services/MVCService.asmx","HellowWord", false,null, success, fail );
}
</script>

这篇关于阿贾克斯(调用Web服务)与MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆