My first choice was to use JQuery. You can use jQuery.ajax with dataType="jsonp". However, this won't work unless the servers supports jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/). Cross domain HTTP requests are a really interesting topic.
After several tries, I decided to do this using ASP.NET (in the code-behind page):
Uri uri = new Uri("http://192.168.0.1/default/query");
if (uri.Scheme == Uri.UriSchemeHttp)
{
WebRequest request = HttpWebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();
}
No comments:
Post a Comment