开发者

WCF data service cross domain problems jquery

I have created an WCF data service in a new asp.net web application and i want to call this web service from another web application using jquery, but it always returns null.

My jquery call looks like this:

$.ajax({
    type: "GET",
    url: "http://localhost:2916/PennyBridge.svc/Memb开发者_如何学Pythoner",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
   },
    error: function (xhr) {
        alert(xhr.responseText);
    }
});

Note that "http://localhost:2916/PennyBridge.svc/Member" works in the browser but since the jquery call is from localhost:3410 i assume its a problem with cross domain.

I have been reading that i should use jsonp for this, but i have a hard time figuring it out.

What do i need to use jsonp? Do i need to configure my WCF data service?


expose your wcf as jsonp custom binding and follow this link to fix cross domain issue.

you need to download those classes from microsoft

http://jasonkelly.net/2009/05/using-jquery-jsonp-for-cross-domain-ajax-with-wcf-services/


i was in your shoe few weeks ago and here is the solution:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜