小编wot*_*ame的帖子

麻烦与ajax POST调用WCF服务

我从ajax调用WCF服务,我可以让它作为GET请求而不是POST请求.所以:

    [OperationContract]
    [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    public UserObject GetUser(string name)
    {
        // Add your operation implementation here
        var uo = new UserObject() { CustClass = "Guest", fname = "Chris", Email = "chris@Something", IsMobile = false };
        uo.fname = name;
        return uo;
    }
Run Code Online (Sandbox Code Playgroud)

var json = { "name": "test" }; 
$.ajax({ //get user name and customer class
    type: "GET",
    url: "WritingAnalysisService.svc/GetUser",
    data: json,
    processData: true,
    contentType: "application/json",
    timeout: 10000, 
    dataType: "json", 
    cache: false,
    success: function …
Run Code Online (Sandbox Code Playgroud)

asp.net ajax wcf

5
推荐指数
1
解决办法
2488
查看次数

标签 统计

ajax ×1

asp.net ×1

wcf ×1