I recently used web.DownloadString() function in my ASP.Net MVC application and I'm wondering that Is there any equivalent java script function for ASP.Net method web.DownloadString
????
1 Answer
There's no such equivalent in javascript because of the Same Origin Policy
restriction built in browsers which prevents you from retrieving resources on other domains. But assuming you could overcome this restriction (with techniques like CORS
) you could use AJAX. Alternatively you could setup a controller action on your domain which will act as a bridge -> this action will retrieve resources from remote domains using a WebClient and then you could use javascript to send an AJAX request to this controller action.
XMLHttpRequest
object, or maybe jQuery's various ajax functions.