我无法从jquery调用webmethod。我认为它关于web.config文件。我如何设置web服务和webmethod的web.config文件?无法从JQuery调用Webmethod
0
A
回答
0
您是否有此代码?
$.ajax({
url: "Services/MyService.svc/Service",
type: "GET",
context: document.body,
contentType: 'application/json; charset=utf-8',
datatype: 'json',
success: function (data) {
// do something
}
});
注意的contentType部分是至关重要的。
如果是这样,请检查Firebug是否出现在“网络”选项卡中的确切错误。 通常,人们根据服务类型有不同的问题 - ASP.NET asmx与WCF svc。有关asmx配置,请参阅How to let an ASMX file output JSON。对于WCF,你需要设置的web.config允许Web脚本,像这样:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
再后来将服务配置为使用行为:
<services>
<service name="MyProject.Services.MyService">
<endpoint address="/Services/MyService.svc" behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" contract="MyProject.Services.MyService"/>
</service>
</services>
</system.serviceModel>
相关问题
- 1. jQuery ajax无法调用WebMethod
- 2. 无法使用jquery json调用webmethod
- 3. 无法使用jQuery Ajax调用Page WebMethod?
- 4. 无法从asp.net(WEBMETHOD)值,并使用jquery
- 5. 无法在ajax调用ASPX调试WebMethod
- 6. ASP.NET无法使用JQuery使用WebMethod
- 7. 如何从jQuery ajax调用webmethod?
- 8. WebMethod没有从asp.net中的jquery调用
- 9. ASP .NET:无法调用页面的WebMethod使用jQuery
- 10. 无法获得调用webmethod的ajax
- 11. $ .getJSON无法调用Codebehind [WebMethod] asp,net
- 12. 使用jQuery调用webMethod返回HTML ... webMethod根本没有调用
- 13. jQuery Ajax不调用C#Webmethod
- 14. jQuery Ajax和WebMethod调用
- 15. jQuery ajax调用asmx webmethod
- 16. jQuery Ajax调用asp.net webmethod
- 17. 从c调用远程webmethod#
- 18. asp.net从Javascript调用WebMethod asyncronous
- 19. 无法加载WebMethod
- 20. 在ASP.NET WebForms中使用jQuery调用'WebMethod'
- 21. 使用jquery跨域webmethod调用
- 22. 调用的WebMethod用的MapPageRoute jQuery中
- 23. C#调用webmethod
- 24. AngularJS调用webmethod
- 25. 从ajax调用调试c#webmethod?
- 26. 无法从JQuery调用页面方法?
- 27. 从ASP.Net获取更好的错误信息[WebMethod]从JQuery调用
- 28. jquery Ajax在asp.net中调用WebMethod
- 29. ASP.NET 4 jQuery的AJAX调用的WebMethod
- 30. jQuery的$。阿贾克斯()调用的WebMethod
这样做只是抽查了答案,我没有看到任何值得评分的答案。也许只是我,但也许他可以提供他在其中一些问题上所做的。 – 2010-11-08 21:56:02
好吧,请下来:)我确实检查了我的问题,并将一些答案标记为“答案”。 – pegasus 2010-11-08 22:02:32