www.webdeveloper.com
Results 1 to 3 of 3

Thread: Import a text file

  1. #1
    Join Date
    Sep 2010
    Posts
    13

    Import a text file

    I have some Javascript which says this:

    var contentString =
    '<div id="content">'+
    '<p>some text which I have written directly into the Javascript</p>'+
    '</div>';

    Now that is fine when the text is only one line long. Suppose it's longer?
    What I want to do is have Javascript give the variable contentString its text from a hosted text file in a similar manner to the way Javascript can insert more Javascript using a hosted .js file.

    I illustrate what I need to do using some "dummy" Javascript:

    var contentString =
    <someInstruction src="//mytextfile.txt">

    Any ideas would be appreciated.

  2. #2
    Join Date
    Jan 2005
    Posts
    349
    Parse your file with one of the many AJAX scripts, your server side does not need to be particularly dynamic for AJAX to be useful.

  3. #3
    Join Date
    Sep 2010
    Posts
    13

    Import a text file

    Thank you for that omnicity, but I'll probably just leave well alone because my experience of Ajax is limited, unless you can direct me to some examples.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles