1

I am still new in ASP.Net but and I have got some questions. I know about jQuery-ajax cross-domain policy, but can I do something when I have this js file associated with an ASPX page? I mean - in ASP I can use WebClient or HttpWebRequest/Response (cross-domain), so maybe there is some solution to use that with jQuery ?

So far i have only came up with:

WebClient wClient = new WebClient()
byte[] arr = wClient.DownloadData("http://www.google.com/");
Response.Write("<div id='placeholder' >");
Response.Write(System.Text.Encoding.UTF8.GetString(arr));
Response.Write("</div>");

And then with jQuery

var c = $('#placeholder').find('#content'); //assuming that there is some tag with id=content
$('body').append(c)

Is there more elegant solution? Do you know some tutorials?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
el vis
  • 1,302
  • 2
  • 16
  • 32

1 Answers1

0

You can Proxy your Requests from within your page, but then your Server has to do the work, and probably this isn't really necessary. So you should try to load data cross Domain. This Article Probably will help you: how to avoid cross domain policy in jquery ajax for consuming wcf service?

Since the link to the "jQuery-Part" of the mentioned article is non-functional - heres another SO-Querstion about jQuery-cross-domain:

jQuery AJAX cross domain

Community
  • 1
  • 1
TGlatzer
  • 5,815
  • 2
  • 25
  • 46
  • Thanks for response, problem here is that i don't have access to page which i want to load - like google.com, so I can't install there WCF and manipulate this. – el vis Aug 29 '12 at 07:45