本文介绍了wcf服务在从Jquery调用时给出错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jquery中调用wcf服务的简单方法,但它在控制台中抛出错误。

可以在这里任何一个请告诉我原因。

i am calling the wcf service simple method in jquery but it was throwing error in console.
can any one here please tell me the reason.

$.ajax({
	type: "GET",
	url: "Service.svc/GetName",
	dataType: "json",
	async: false,
	success: function (data) {
		alert('hello how are you');
		alert(data);
	},
	error: function (d, h) { alert(d + h.responseText); }
});





服务位于根目录。

服务定义: -



service is residing on root directory.
Service definition :-

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
    public void DoWork()
    {
    }

    public string GetName()
    {
        return "hello";
    }
}

推荐答案





服务位于根目录。

服务定义: -



service is residing on root directory.
Service definition :-

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
    public void DoWork()
    {
    }

    public string GetName()
    {
        return "hello";
    }
}


这篇关于wcf服务在从Jquery调用时给出错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:39