Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    89
    Thanks
    51
    Thanked 0 Times in 0 Posts

    How to do this with pure js?

    Hi

    I'm using jQuery to load an external file into a page, and then write it to a div:

    Code:
    jQuery.get('myfile.txt', function(data) {
    						
    	$("#testDiv").html(data);
    
    });
    I'm wondering how to do the same with pure js?

    I can do the write bit, but I don't know how to load the txt file as a string

    Code:
    var div = document.getElementById("testDiv");
    div.innerHTML = what goes here? ;
    I'd do it using jquery, but I actually want to load the jquery file as a string, so I can load it into localStorage.

    Thanks guys

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    In "pure" javascript, you have to manually write your XHR, process the AJaX request, test for statusResponse and statusText, then write that to the element.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • Users who have thanked WolfShade for this post:

    shaunthomson (11-02-2012)

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    89
    Thanks
    51
    Thanked 0 Times in 0 Posts
    Cheers WolfShade


  •  

    Posting Permissions

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