Populate menu with a text file eg text.txt Populate menu with a text file eg text.txt database database

Populate menu with a text file eg text.txt


You can do this using .get:

  var textFile = "SCHEME://DOMAIN/FILENAME.txt";          jQuery.get(textFile, function(textFileData) {                   //Parse file and populate menu based on specs.         //textFileData will have the text          }         

If you want the text back for each line you can do (assuming the names are separated by a newline):

   var EachLineInTextFile= textFileData.responseText.split("\n");            for (var i = 0, len = EachLineInTextFile.length; i < len; i++)    {      //This will give you each name from here you can put the name where you want it   } 

A sample would be:

<script type="text/javascript">    $(document).ready(function () {        var textFile = "http://localhost/MyDomain/Menu.txt";        jQuery.get(textFile, function (textFileData) {            var EachLineInTextFile = textFileData.responseText.split("\n");            for (var i = 0, len = EachLineInTextFile.length; i < len; i++) {                STORE_TO_REPLACE = EachLineInTextFile[i];                //STORE_TO_REPLACE: I would have to the entire format of your file to do this.            }        })    });           </script>

From here, if you need help replacing the values in your list take a look at this article

Or, if you want to replace them all you can use .each to iterate through your list.