A better way to read text files into html? Currently I'm making a website that has a to-do list that will probably become quite long to write in html. So I decided to make a shorter version for me to write that I find more comfortable to read.

What I am currently doing is using ajax to read the text file from the server. Once the file has been stored into a string, it's sent to a function which formats it correctly for html. After that, it's returned into a variable that is now stored into a container div using jquery div. 

This is my javascript code:

var todoListMake = function( reading ){
        var wanted =reading.split("\n");
        var newString = "";
        for( var i = 0; i &lt; wanted.length; i ++ )
        {
            if( wanted[i] === "\n" )
                continue;
            /* Place text formatting code below */
            wanted[i] = wanted[i].replace("&lt;b&gt;","&lt;strong&gt;");
            wanted[i] = wanted[i].replace("&lt;/b&gt;","&lt;/strong&gt;");
            wanted[i] = wanted[i].replace("&lt;c&gt;","&lt;span class=\"cutWord\"&gt;");
            wanted[i] = wanted[i].replace("&lt;/c&gt;","&lt;/span&gt;");

            if( wanted[i].search("[X]") != -1 )
            {
                wanted[i] = "&lt;span class=\"workDone\"&gt;" + wanted[i].replace("[X]","") + "&lt;/span&gt;";
            }

            if( wanted[i].search("&lt;ul") === -1 &amp;&amp; wanted[i].search("&lt;/ul") === -1 )
                wanted[i] = "&lt;li&gt;" + wanted[i]; // Open the list if no ul tags

            if (i === (wanted.length-1) )
            {
                newString += wanted[i];
                break;
            }// Break early because the rest cannot be processed correctly

            if( wanted[i].search("&lt;/ul") != -1 )
                wanted[i] += "&lt;/li&gt;"; // Close the list at the end of each ul

            if ( wanted[i + 1].search("&lt;/ul") != -1 )
                wanted[i] += "&lt;/li&gt;";// Close the list of regular data

            //alert(wanted[i]);
            newString += wanted[i];
        }
        return newString;

};

window.onload = function(){
        $.get("textData/todoData.txt", function(data) {


 var compiledData = todoListMake( data );
            $("#todoList").append( compiledData );
        });
    };


And then read from the text file like this:

&lt;ul  id="todoList" class="workList"&gt;
    &lt;h2&gt;Release 1:&lt;/h2&gt; &lt;span class="important"&gt; Completed &lt;/span&gt;

    &lt;h2&gt;Release 2: &lt;span class="important"&gt; Current Version &lt;/span&gt;&lt;/h2&gt;
        &lt;ul&gt;    
            &lt;b&gt;Core Additions&lt;/b&gt;
            &lt;ul&gt;
                [X] Save Progress
                [X] &lt;c&gt;14&lt;/c&gt; 9 New Levels
            &lt;/ul&gt; 

            &lt;b&gt;Programmers Check List&lt;/b&gt;
                &lt;ul&gt;
                    [X] Add functionality to Level Restart
                    [X] Add checkpoint floater
                &lt;/ul&gt; 

            &lt;b&gt;Bug Fixes&lt;/b&gt;
                &lt;ul&gt;
                    [X] Hanging on Slopes teleport you
                    [X] Hanging on Slopes froze the game
                    [X] Fixed Menu overlay problem
                &lt;/ul&gt;
        &lt;/ul&gt;
&lt;/ul&gt;
What do you mean with the variable name wanted? I don't understand what it has anything to do with what you are doing, so it's a badly chosen name.

if( wanted[i] === "\n" )
    continue;


This won't do anything. Since you split by "\n", there will be no line breaks leftover. I assume you want wanted[i] === "". Also consider .trim()ing all you lines, otherwise a stray white space will break this.

if (i === (wanted.length-1) )
    {
        // [...]
        break;
    }// Break early because the rest cannot be processed correctly


I'm not sure why you are "breaking early" here. Your condition triggers for the last line, so it's not really "early".

newString += wanted[i];


Repeated string concatenation is a slow process and uses a lot of memory. Instead just leave your strings in the array and at the end just return wanted.join();

EDIT: One more thing: Both the original div and the other ul you later add inside have the same id. That's invalid.

EDIT: Regarding the ID: In your script you have $("#todoList").append( compiledData ); so there's obviouly an element with the id todoList, but your template has the code &lt;ul  id="todoList" class="workList"&gt; in it, so you are creating a second element with the same ID.