我有一个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>