I have created and hosted my WCF REST API Using WCF REST Starter Kit preview2. Which supports Dynamic Response and Request format type (XML and JSON).Everything is working fine if I consume the service in same domain through Jquery, Microsoft.Http.
My cs code is as following:
private void GetData()
{
string url = string.Format("http://myhost/Services/UserService.svc/people/");
HttpClient client = new HttpClient();
HttpResponseMessage responseMessage = client.Get(url);
responseMessage.EnsureStatusIsSuccessful();
using (responseMessage)
{
string res = responseMessage.Content.ReadAsString();
Response.Write(res);
}
}
now when I try to consume my service using Jquery from another domain Response is comming in IE8 but in Mozilla and Chrome I am getting null response My jquery code is as following :
function loadData() {
var path = "http://myhost/Services/UserService.svc/people/";
$.ajax({
type: "GET",
url: path,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function(response) {
if (response != null) {
displayData(response);
}
}
});
}
I have also try to set Data type:"jsonp" and .getJson() method call.