Ajax没有调用WCF服务

时间:2014-11-18 12:31:36

标签: javascript c# ajax wcf

我在IIS上成功托管了一项服务。

确保应用程序正在运行。

我已通过ajax调用此服务:

 var parameters = {

            'EmailID':EmailID,
            'Password':Password
            };

           $.ajax({
            url: "http://localhost:85/MobileECommerceTesting/Service1.svc/validateLogin",
            data: JSON.stringify(parameters),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            type: "POST",
            cache: false,
            success: function (Data) {
               alert("asdsad");
            },
            error: function () {
                alert("Error in Saving.Please try later.");

            }
        });

但它没有给这项服务打电话。

可能是什么问题?

修改

enter image description here

EDIT2:

网络标签:

enter image description here

1 个答案:

答案 0 :(得分:1)

看看这个问题:

the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'

它可能与您的绑定有关,它不期望内容类型application / json。您必须使用webHttpBinding与WCF一起创建“类似REST”的服务。

相关问题