如何使用仅客户端代码调用asmx webservice?

时间:2021-10-02 15:39:10

So, google and stack are garbled with many different approaches to this problem, which I thought would be easily researchable.

因此,谷歌和堆栈是乱码与这个问题的许多不同的方法,我认为这很容易研究。

I want to know the best/cleanest way to call a .net .asmx based webservice, from pure javascript client side code. i.e. No tags. Nearly every reference to this question provides asp.net server-side code examples, which I don't want.

我想知道从纯JavaScript客户端代码调用基于.net .asmx的web服务的最佳/最干净的方法。即没有标签。几乎每个对这个问题的引用都提供了我不想要的asp.net服务器端代码示例。

I guess I could use jquery on the client side. I think (but am unsure) that Microsoft has a client-side javascript library that can be used to make an ajax call to a webservice as well.

我想我可以在客户端使用jquery。我认为(但我不确定)微软有一个客户端javascript库,可以用来对web服务进行ajax调用。

I'm happy to modify my server-side asmx webservice to be JSON compatible (i.e. the client-side code here doesn't have to handle soap).

我很高兴修改我的服务器端asmx webservice与JSON兼容(即客户端代码在这里不必处理soap)。

Must I adopt jquery? Or is there another way of doing this?

我必须采用jquery吗?还是有另一种方法吗?

1 个解决方案

#1


1  

For those who have the same question, my research has shown that the safest approach to this is to harness a client-side library. In the end I've gone with JQuery on the client side, coupled with JSON enabled asmx based webservices (subject to the links in the comments above)

对于那些有相同问题的人,我的研究表明,最安全的方法是利用客户端库。最后我在客户端使用了JQuery,加上基于JSON的asmx基于webservices(受上面评论中的链接的影响)

#1


1  

For those who have the same question, my research has shown that the safest approach to this is to harness a client-side library. In the end I've gone with JQuery on the client side, coupled with JSON enabled asmx based webservices (subject to the links in the comments above)

对于那些有相同问题的人,我的研究表明,最安全的方法是利用客户端库。最后我在客户端使用了JQuery,加上基于JSON的asmx基于webservices(受上面评论中的链接的影响)