Reputation: 349
I used Webrequest in c# to get url Content. Then how to get url content using JavaScript/ Jquery please help to get url content...
WebRequest request = WebRequest.Create ("https://api.pcpartpicker.com/api/2015.1/part/categories/?apikey=XXXXXXXXXXXXXX");//Any Other Google Https Address
WebResponse response = request.GetResponse ();
This code is working and i got data from that url and how we write this code in Javascript
Upvotes: 1
Views: 898
Reputation: 705
You can try this code
function httpGet(theUrl)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
return xmlhttp.responseText;
}
}
xmlhttp.open("GET", theUrl, false );
xmlhttp.send();
}
Upvotes: 1
Reputation: 3580
It is not possible to get external webpages content in your site with javascript.
only js,images formats are allowed from external source into your site
Upvotes: 1