简体   繁体   中英

Ajax not calling WCF service

I have hosted a service sucessfully on IIS.

Made sure that application is running.

I have given call to this service through ajax as:

 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.");

            }
        });

But its not giving call to the service.

What can be the problem?

EDIT:

在此处输入图片说明

EDIT2 :

Network Tab:

在此处输入图片说明

Take a look at this question:

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

It might be related to your binding, which does not expect the content type application/json. You must use webHttpBinding to create "REST-like" services with WCF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM