ajax发出请求wcf返回" 400错误请求"

时间:2016-01-24 13:02:11

标签: jquery json ajax asp.net-mvc wcf

抱歉我的英语。

我有wcf方法:

    [OperationContract]
    [WebInvoke(UriTemplate ="TestFunction", Method = "POST",ResponseFormat =WebMessageFormat.Json,RequestFormat =WebMessageFormat.Json,BodyStyle =WebMessageBodyStyle.WrappedRequest)]
    string TestFunction(string name);

public string TestFunction(string name)
    {

        return "Successed!";
    }

我的ajax方法:

<script type="text/javascript">
       $(function () {
           var wcfurl='http://192.168.200.100/Searching.BE.Service/WCFRESTService.svc/TestFunction';
           $.support.cors = true;
           jQuery.support.cors = true;
           $.ajax({
               crossDomain: true,
               type: 'POST',                                
               processdata: true,
               data:{"name":"Denis"},
               url: wcfurl,
               success: function (data) { alert(data); },
               error: function (data) { console.log(data);},
               ContentType: 'application/json; charset=utf-8',
               dataType: 'json',
           });
       });
   </script>

返回服务:

{readyState: 4, responseText: "<?xml versi...", status: 400, statusText: "Bad Request"}

我尝试过使用JSON.string等等。问题是什么?

0 个答案:

没有答案
相关问题