JQuery调用WCF:.ajax起作用,而.post不起作用

JQuery调用WCF:.ajax起作用,而.post不起作用,jquery,ajax,wcf,post,Jquery,Ajax,Wcf,Post,使用ajax调用WCF服务时,.ajax在.post正常工作时出错:传入消息的消息格式为“Raw”。操作的预期消息格式为“Xml”、“Json” 有人能说出这两个电话的区别吗?谢谢 //WCF [OperationContract] public ColumnSelector[] returnColumnInformation(string templateid, string userid) { } // ColumnSelector [DataContrac

使用ajax调用WCF服务时,.ajax在.post正常工作时出错:传入消息的消息格式为“Raw”。操作的预期消息格式为“Xml”、“Json”

有人能说出这两个电话的区别吗?谢谢

//WCF
    [OperationContract]
    public ColumnSelector[] returnColumnInformation(string templateid, string userid)
    {
    }

// ColumnSelector
[DataContract]
public class ColumnSelector
{
    [DataMember]
    public string ColumnName { get; set; }
    [DataMember]
    public string ColumnOrder { get; set; }
    [DataMember]
    public string ColumnDisplay { get; set; }

    public ColumnSelector()
    {
        ColumnName = "";
        ColumnOrder = "";
        ColumnDisplay = "";
    }

    public ColumnSelector(string _name, string _order, string _display)
    {
        ColumnName = _name;
        ColumnOrder = _order;
        ColumnDisplay = _display;
    }
}

// working:
        $.ajax({
            type: "POST",
            url: "AjaxService1.svc/returnColumnInformation",
            data: JSON.stringify({templateid: "1", userid: "300"}) ,
            dataType: "json",
            processData: true,
            contentType: "application/json; charset=utf-8",
            error: function (xhr, ajaxOptions, thrownError) {
                var err = eval("(" + xhr.responseText + ")");
                alert(err.Message);
            }
        })
        .done(function (msg) {
         alert("POST Data Saved: " + msg);
        });


// not working: The incoming message has an unexpected message format 'Raw'. The expected message
// formats for the operation are 'Xml', 'Json'.
    $(document).ready(function () { 
        $("#AjaxPost").click(function () {
            $.post("AjaxService1.svc/postColumnInformation",
            {templateid: "1", userid: "300"},
            function (data, status) {
                alert("Data: " + data + "\nStatus: " + status);
            },
            "json"               
            )
             .done(function () {
                 alert("second success");
             })
              .fail(function (xhr, ajaxOptions, thrownError) {
                  var err = eval("(" + xhr.responseText + ")");
                  alert(err.Message);
              })
                .always(function () {
                    alert("finished");
                });
            return false;
        });

您在.post方法中请求的url与在.ajax方法中请求的url不同,这可能是由于该特定url出现了问题。.post用法看起来是正确的,应该产生与.ajax用法相同的结果