如何使用jQuery使用Asmx Web服务? [英] How to consume a asmx web service with jQuery?

查看:115
本文介绍了如何使用jQuery使用Asmx Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上看到了许多不同的答案,并做了很多复制和粘贴操作.只是对我不起作用.谁能告诉我为什么? 我很沮丧> _< 我必须在我的web.config文件中做些什么吗? 我不明白,即使我的"WebService.asmx/add"也不会从浏览器返回任何内容(因为没有这样的链接.)jQuery如何获得任何结果?我必须添加一些httphandlers,对吧?

I have seen some many different answers on the web and did a lot of copy and paste. It just doesn't work for me. Can any one tell me why?? I am so frustrated >_< Do I have to do something on my web.config file? I don't understand that even my "WebService.asmx/add" won't return anything from my browser (because there is no such a link.) How would jQuery get any result? I must add some httphandlers, right?

推荐答案

我在您的图像中看到,您的web方法没有静态方法.

As i see in your image, your webmethod does not have static method.

为了使用服务,Web方法应该是静态方法. WebMethod和静态

A webmethod should be a static method, in order to consume a service. WebMethod and Static

[WebMethod]
Public static string HelloWorld()
{
 return "Hi";
}

请访问此链接以获取更多信息

Please go through with this links for more information

  1. WebService和Jquery

这篇关于如何使用jQuery使用Asmx Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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