/    Sign up×
Community /Pin to ProfileBookmark

J.S.-Getting Data From External File

Is it possible to get data from an external source like a text file using javascript?

What I am looking to do is to pull data from a text from and put it into a textarea box.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Apr 16.2004 — <i>
</i>&lt;html&gt;
&lt;script type="Text/javascript"&gt;var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version &gt;= 5)
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
} catch (E) {
xmlhttp=false
}
}
@else
xmlhttp=false
@end @*/
if (!xmlhttp) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false
}
}

function loadXML(url){
xmlhttp.open("GET", url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.forms[0].theText.value=xmlhttp.responseText
}
}
xmlhttp.send(null)
}
&lt;/script&gt;

&lt;body onload="loadXML('http://www.google.com')"&gt;

&lt;form&gt;
&lt;textarea id="theText" cols="55" rows="15"&gt;&lt;/textarea&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @burozoption spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...