Nick Kahn
Nick Kahn

Reputation: 20078

how do i get value which returns from service (WCF) using JQuery?

client:

 $("#btn").click(function (event) {
                $.getJSON('http://host/myservice.svc/GetCount?method=?', { Id: '2' }, function (customer) {

                   //how to get an value ??? here ????                    
                });
                //return false;
            });

Server

public long GetCount(string method, string Id)
{ 
  return 100;
}

Upvotes: 1

Views: 151

Answers (1)

kobe
kobe

Reputation: 15835

Do you have jsonP endpoint which automatically converts and sends the jsonp object to the user. if jsonP you should get straightway.

If it is not jsonp end point , change your backend to a well formated string which is of jsonP notation and do a eval at the UI.

You will have some cross browsers issues also.follow the below link

http://www.west-wind.com/weblog/posts/107136.aspx

Custom jsonp binding

<endpoint address="ajax" binding="customBinding" bindingConfiguration="jsonpBinding" behaviorConfiguration="JsonBehavior" contract="InterfaceGoeshere"/>

Upvotes: 1

Related Questions