469,276 Members | 1,932 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

How to import file inside javascript

10
Hi.
I want to import a file inside javascript..
for ex:<%@page import="java.util.ArrayList">
how i can import this file inside javascript
May 26 '10 #1
4 1897
Dormilich
8,651 Expert Mod 8TB
if you have this file on the server, you can import its text content via AJAX. the text is then available through the .responseText property (given that the file is not processed on the server).
May 26 '10 #2
aaaash
10
@Dormilich
Can u plz tell how we can import its text content via AJAX. i have no idea abt AJAX. Can't we import using javascript?
May 26 '10 #3
Dormilich
8,651 Expert Mod 8TB
as I said, do a simple AJAX request.
Expand|Select|Wrap|Line Numbers
  1. // a very basic procedure, may not work in IE (kindly refer to the link on the bottom of this post for further information)
  2. var xhr = new XMLHttpRequest();
  3. xhr.open("POST", "your_file.txt", false);
  4. xhr.send();
  5. var txt = xhr.responseText;
  6. // now you have the content of "your_file.txt" in the txt variable
further introductions & tutorials you can find in our Offsite Links, AJAX section.
May 26 '10 #4
aaaash
10
@Dormilich
ok thank you..
May 26 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Frederik S | last post: by
2 posts views Thread by Eric Caron | last post: by
2 posts views Thread by kalaivanan | last post: by
2 posts views Thread by gaya3 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.