Click to See Complete Forum and Search --> : How to use HTTP GET REQUEST with JS?


merupe
09-24-2003, 02:09 PM
I want to grab the contents of a webpage and have used vbscript to do this, but not sure how to do this with JavaScript....

Can anyone provide a sample of how to do an http get request using Javascript?

TIA

Jona
09-24-2003, 02:16 PM
You will need to parse the URI to retrieve the variables from it.

[J]ona

merupe
09-24-2003, 02:37 PM
I have used this vbscript code to get the contents of a remote webpage and I am wonding if someone can provide a sample that will do the same thing using JavaScript?

<%

Dim objXMLHTTP, xml


Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xml.Open "GET", "url_goes_here", False

' Pull the data from the web page
xml.Send

Response.Write xml.responseText


Set xml = Nothing
%>

Jona
09-24-2003, 02:50 PM
That code is VBScript in ASP--you must have a server-side language to pull data from the server.

[J]ona

pyro
09-24-2003, 02:51 PM
Jeff Mott has posted a nice one: http://forums.webdeveloper.com/showthread.php?s=&threadid=10893#post58250

merupe
09-24-2003, 03:04 PM
I took a look at that thread and did not see anything for doing a URLGet using Javascript. Everything seemed to do with parsing out url string variables.

I want to have a page that contains a JavaScript (eg. gethtml.htm) that will go out to a remote server and return the entire contents of a specfic webpage (thispage.htm) and write it to my "gethtml.htm" page.

Is this possible with only JavaScript? If so, How?

Thanks,

pyro
09-24-2003, 03:10 PM
Ah, sorry. Didn't understand what you wanted.

Anyway, no, due to security protocols, that is not possible with JavaScript...

merupe
09-24-2003, 03:17 PM
Thanks Pyro,

So, how do "news" sites create those Javascript "news feeds" that you are able to paste into a site that "download" the latest news stories?

Just trying to figure out how to use JavaScript to pull information from one website into another??

Thanks again!

pyro
09-24-2003, 03:27 PM
I'm not aware of "JavaScript news feeds"... They must either use an XML file (preferrably) or some PHP (or other serverside language) to get the content...