Tag: wcf

使用JQuery和WCF连接JSONP

我正在尝试使用JQuery中的JSONP进行跨域调用。 在IE中,警报方法从未执行过。 在FF / Safari / Chrome中,它始终为空。 我看着Fiddler,WCF方法的结果正如我所料,这是: method({“Name”:”blah1″,”Data”:”blah2″}); 这是我的JavaScript: $.getJSON(“http://localhost:5603/MyService/?method=test”, null, function (result) { alert(“in test: ” + result); $(“#spText”).html(result); }); 这是WCF方法: [OperationContract] [WebInvoke(UriTemplate = “”, Method = “GET”, BodyStyle=WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] public Message Blah() { var j = new { Name = “blah1”, Data = “blah2” }; JavaScriptSerializer s = new JavaScriptSerializer(); […]

WCF 4,JSONP和jQuery导致parsererror

我已经尝试了几乎所有我能想到的东西,但是我仍然遇到了对我的ajax调用WCF服务的问题。 我的WCF服务有如下方法: //[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = “POST”)] [WebGet] public string Test(int value) { return string.Format(“You entered: {0}”, value); } 正如Patrick Thomas在Twitter上所提到的,我也尝试过使用[WebGet(BodyStyle = WebMessageBodyStyle.Wrapped)]和[WebGet(BodyStyle = WebMessageBodyStyle.WrappedResponse)]而没有运气。 和配置如下: 该服务位于不同的域,所以我将我的数据格式化为JSONP: $.ajax({ cache: false, async: true, type: “GET”, // Was “POST” dataType: “jsonp”, url: “http://mydomain.com/TestService.svc/Test?callback=?”, data: dataToPost, contentType: “application/json;charset=utf-8”, success: function (msg) { var testMsg = JSON.parse(msg); var […]

Access-Control-Allow-Origin不允许使用origin http:// localhost:1716

我有这个错误 XMLHttpRequest无法加载http://localhost:81/Test/Service.svc/SetJSON 。 Access-Control-Allow-Origin不允许使用http://localhost:1716 。 当我使用jquery调用wcf web服务时。 $.ajax({ type: ‘POST’, url: webmethod, data: ‘{“data”:”Darshana”}’, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function (msg) { alert(msg.d); }, error: function (e) { alert(“Unavailable”); } }); 这是为什么? 任何帮助。 感谢名单..

使用WCF以及jquery(AJAX)和html客户端的文件上载服务

我想知道如何通过使用jquery进行AJAX调用来使用WCF上传文件。

Jquery Rest与WCF 3.5的通信

我正在测试在asp.net mvc站点和WCF 3.5服务之间交换rest消息的基础知识。 该服务使用在codeplex上找到的WCF REST入门工具包中的模板构建。 我想用jquery交换json消息。 REST Singleton服务正常运行,它还提供了所有可能调用的示例,在uri的末尾添加了help参数。 我到达使用内置的jquery $ .getJSON执行GET请求。 我在执行PUT(用于更新值)和POST时遇到问题。 $.ajax({ type: “PUT”, dataType: “json”, url: “http://localhost:1045/Service.svc/?format=json”, data: ‘{“Value”:testvalue}’ }); 对此最好的方法是什么? 是否有可能根本不使用Ajax女士,绕过它是否正确?

Jquery将数据传递给ajax函数

我在将数据值传递给Jquery Ajax函数时遇到问题。 我一直在使用getJSON函数,但工作正常,但现在我想使用ajax函数,我无法弄清楚如何传入值。 $.ajax({ type: “POST”, url: ‘../../../WebServices/ImageLibrary.svc/getimagesinfolder’, dataType: ‘json’, data: “{ ‘id’, ‘2’ }”, contentType: “application/json; charset=utf-8”, success: function (data) { alert(‘hello’); } }); 这是正确的吗? 谁能告诉我哪里出错了? 谢谢

关于ASP.Net中的弹出窗口

我有一个gridview ,其中包含一个details button作为最后一列。 我的aspx: <asp:ImageButton ID="Ibtn_Details" runat="server" ImageUrl="~/Images/detail.png" CommandArgument='’ CommandName=”Detail” CausesValidation=”false” /> 我想做的是: 当用户单击details button ,打开弹出窗口(对话框窗口) 。 在这个窗口中我想放入一些asp.net服务器控件(比如网格视图)。 所以我希望这个窗口启用/允许我访问后面代码中的那些控件。

带参数的jQuery WCF服务MVC2 VS2010 .NET 4.0调用失败

在Visual Studio 2010中,我创建了一个新的启用Ajax的WCF服务 [ServiceContract(Namespace = “TestWCFAjax.Bridge”)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Bridge { [OperationContract] public string DoWork() { return “jQuery WCF call without parameters from MVC2 works.” ; } [OperationContract] public string DoWork1(string parm) { return parm + ” jQuery WCF call with parameters from MVC2 fails”; } 在Home Controllers Index.aspx视图中,我添加了jQuery: 函数CallWebMethod(){ $.ajax( { type: […]

与jQuery相比,新的oData javascript库(来自MSFT)

与使用jQuery相比,新的Javascript OData库有什么好处? http://blogs.msdn.com/b/astoriateam/archive/2011/02/08/new-javascript-library-for-odata-and-beyond.aspx

jQuery $ .ajax对WCF服务的调用返回400 Bad Request

(最后更新) 我正在使用不熟悉的技术开发一个想法。 我写了一些WCF服务,但我从来没有做过任何高级配置。 这是我第一次深入了解jQuery。 前提是我创建一个WCF服务来获取分支信息,由jQuery检索。 我的第一次搜索产生了这个页面: http : //www.codeproject.com/KB/aspnet/WCF_JQUERY_ASMX.aspx#2我正在使用它作为我的代码的基础。 我最初是作为一个跨站点设置开始的,我摆脱了,看看我能不能让这个东西工作。 我搜索了堆栈溢出,没有post解决了我的400 Bad Request问题。 我的web.config中的代码: 我的界面代码: [ServiceContract] public interface IGeoDataService { [OperationContract] [WebInvoke(Method = “POST”, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] List GetBranches(); } // Use a data contract as illustrated in the sample below to add composite types to service operations. [DataContract] public class BranchData […]