I'm making ajax request to the generic handler Handler.ashx
, which forwards this request to a REST service in another domain. Handler is used to achieve cross-domain call.
I get the data in Firefox & Chrome. But not in Safari on Windows 7(Ver. 5.1.7)
$.ajax({
url: 'Handler.ashx',
type: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
timeout: 20000,
data: data,
success: function (received_data) {
// Process data
},
error: function (err) {
console.log(err);
}
});
My Handler.ashx
code:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri("http://xxx.xxx.xx.xxx/MyWebService/Service.svc/DownloadFile"));
req.ContentType = "application/json; charset=utf-8";
req.Timeout = 60000;
using (WebResponse resp = req.GetResponse())
{
StreamReader reader = new StreamReader(resp.GetResponseStream());
string responceFromService = reader.ReadToEnd();
context.Response.ContentType = "application/json; charset=utf-8";
context.Response.Write(responceFromService);
}
The error I get is:
NETWORK_ERR: XMLHttpRequest Exception 101