Search code examples
javascriptdropboxgoogle-drive-api

Javascript read from Google drive document or dropbox text file


I have a Javascript array of youtube videos.

var vids = ['aHMeS7VFRZ8', 'qyV5FDUfI34', 'QGjYJ_dnlQE', 'kcgs1UHifRA']

I want to let my friend edit it easyly and modify our web page. He could modify a google drive spreadsheet or document or some text file in dropbox. Can Javascript read from an external file ? No PHP!

XMLHTTP

not easy .. http://en.wikipedia.org/wiki/XMLHttpRequest#Cross-domain_requests


Solution

  • Actually it's pretty easy (using jQuery)

    Have your friend put a .txt file onto his public dropbox folder with:

    ['aHMeS7VFRZ8', 'qyV5FDUfI34', 'QGjYJ_dnlQE', 'kcgs1UHifRA']

    on your js file do the following:

    
    $.get("http://public-dropbox-file-link", function(data) {
    
        // data will contain the .txt file contents
        // edit:
        var vids = eval(data); // and it will behave as a javascript array
    })