C Sharper
C Sharper

Reputation: 8626

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:

enter image description here

EDIT2 :

Network Tab:

enter image description here

Upvotes: 0

Views: 102

Answers (1)

Cosmin Vană
Cosmin Vană

Reputation: 1582

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.

Upvotes: 1

Related Questions