1

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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

6 Comments

Is there any alternative to get data from web url's
you C# itsself send the url as parameter and read it in server and print it
if the content type is json/js means you can directly use ajax call
and it return XMLHttpRequest: Network Error 0x80070005, Access is denied. Exception in IE inspect element..
yes it is not allowing it is allowing with .js extensions only
|
1

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();    

}

2 Comments

i gave url in xmlhttp.open("GET", theUrl, false ); but it's not getting any data..
i am waiting for your replay

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.