如何在ASP.Net中使用JQuery调用WCF方法 [英] How to WCF method call using JQuery in ASP.Net

查看:64
本文介绍了如何在ASP.Net中使用JQuery调用WCF方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好......



我有两个项目。

1)ASP.Net

2 )WCF



如何在ASP.Net中使用JQuery调用WCF方法.. ??



I尝试一些链接就像使用jQuery调用WCF服务 [ ^ ]。



但我有两个不同的项目。不一样

Hello...

I have Two project.
1)ASP.Net
2)WCF

How to WCF method call using JQuery in ASP.Net..??

I try some link just like"Calling WCF Services using jQuery[^]".

But i have two different project. not same

推荐答案

只有当将ASP.NET应用程序设置为客户端应用程序时,才可以调用WCF函数。如果你将ASP.NET网站作为客户端应用程序,那么你可以触发一个jQuery ajax请求,到一个可以从中调用WCF的网页...比如这段代码,



You can call WCF function only and only if you're having your ASP.NET application set as a client application. If you're having your ASP.NET website as a client application then you can trigger a jQuery ajax request, to a web page where WCF can be called from... Such as like this code,


document )。ready( function (){
// 发起请求
(document).ready(function () { // initiate the request


.ajax({
// 设置属性
url:' page-where-wcf-func-can-be-trigger'
成功:功能(数据){
// < span class =code-comment> if 200
// 数据将包含结果来自你的服务ice
}
});
});
.ajax({ // set the properties url: 'page-where-wcf-func-can-be-trigger', success: function (data) { // if 200 // data will contain the result from your service } }); });





如果你想学习如何创建ASP.NET客户端应用程序,请阅读这篇文章 [ ^ ]相同的应用程序(ASP.NET和WCF Web服务)并允许ASP.NET应用程序使用Web服务;在我的情况下,它是直接的HTTP请求,而不是简单的ajax请求。



If you want to learn how to create ASP.NET client application, please read this article[^] of mine which covers the same applications (ASP.NET and WCF web service) and allows ASP.NET application to consume the web service; in my case it was direct HTTP requests, not simple ajax requests.


这篇关于如何在ASP.Net中使用JQuery调用WCF方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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