开发者

How to call WCF Ria Service/DomainService from Jquery?

开发者 https://www.devze.com 2022-12-15 00:32 出处:网络
I\'m attempting to call a DomainService created using WCF Ria Services from jquery.If I use a POST I get 405 method not allowed. If I use Get, it get javascript errors.Am I missing a configuration ste

I'm attempting to call a DomainService created using WCF Ria Services from jquery. If I use a POST I get 405 method not allowed. If I use Get, it get javascript errors. Am I missing a configuration step? This code results in the 405.

    function GetSearchResults() {
        $.ajax(
    {
        type: "POST",
        url: "/Services/CustomerService.svc/GetCustomerSearchResults",
        data: '{"customerId":1}',
        timeout: 5000,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: Success,
        error: Fail
    });
    }

[EnableClientAccess]
public class CustomerService : DomainService
{
    public List<CustomerSearchResult> GetCustomerSearchResults(string customerId)
    {


        var list = new List<Custo开发者_开发百科merSearchResult>();
        list.Add(new CustomerSearchResult
            {
              Id = 1,
                                   Name = "Me"
            });
        }

        return list;
    }

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号