javascript - Getting the content of text files loaded with RequireJS? -


i using requirejs load jquery , other plugins, follows:

var dependencies = ["order!jquery", "order!plugins/jquery.typewatch",      "order!plugins/jquery.csv-0.71.min", "plugins/jquery.zclip.min"]; require(dependencies, function($) {    // jquery code goes here }); 

this works fine. want use requirejs load text file, i've downloaded requirejs text plugin, , amended code:

var dependencies = ["order!jquery", "order!plugins/jquery.typewatch",      "order!plugins/jquery.csv-0.71.min", "plugins/jquery.zclip.min",    "text!data/mytext.txt"]; require(dependencies, function($) {    // jquery code goes here }); 

looking @ devtools, request working ok - text file being requested. how hold of content of text file?

i tried this, suggested requirejs docs:

require(dependencies, function($, txt) {    console.log(txt); }); 

but txt undefined.

update: if it's relevant, i'm using requirejs 1.0.7, , invoking follows html:

<script data-main="scripts/main.js" src="/scripts/require-jquery.js"></script> 

each function argument corresponds result of loading dependency, specified in list of dependencies. need either declare many arguments dependencies in function, or move text!data... dependency front:

var dependencies = ["order!jquery", "text!data/mytext.txt", ....]; require(dependencies, function($, txt) {     console.log(txt); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -