Get Jitter jit.textfile into javascript js

tommymetz's icon

I'm using jit.uldl to download a long text string from my website. Then I use jit.textfile to view it as text. But now I need to get that text into a js object and I'm having trouble. I used to use jit.str.tosymbol but symbols are limited to 2047 characters. So I need to get the jit.textfile output directly into javascript. Can you please help? I've looked everywhere and can't seem to find any help on this.

I've been successful at getting the jitter matrix into javascript, but I don't know how to look at the text string.

tommymetz's icon

I suppose one option is to save the jit.textfile as a text file and then reload that into javascript. But is there a direct way to pass jit.textfile to javascript?

Nat's icon

You could try my mxj utility to download a url:
https://github.com/natcl/max_geturlcontent

this will output the url content and you can pipe directly to js..

tommymetz's icon

Brilliant! Thank you! I'll give it a try.

tommymetz's icon

Nat, would this be possible inside of javascript? So I can just make a GET call directly within javascript and bypass all this extra patching?

Nat's icon

Sadly I don't think so, I don't think we have access to that api from javascript, that's why I did the java object...

tommymetz's icon

Nat, your utility worked for a short string, but when I tried to get a long string (roughly 3000 characters), max just crashes/closes without any warnings or anything. Any idea what that could be about? The string that the website is returning looks similar to the attached file.

string.txt
txt
Nat's icon

seems to work here with the attachment, can you share the url of the data ?

tommymetz's icon

Ok, so tommymetz.com/test.php is the long one (which crashes max for me) and tommymetz.com/test_short.php is the short one which works. Do they both work for you?

I wonder if it's some sort of java issue on my end?

Thanks for your help with this btw!

Nat's icon

That's strange, both work for mw here...
what's your os, max version ?

tommymetz's icon

windows 7, max 6.0.7. It's weird. It just closes max the second I try and parse the url. I've had that problem when working with mxj objects in the past. No idea what's up. I may just have to do multiple jit.uldl calls to get the string in smaller chunks.

Thanks a ton for your help tho. Maybe I'll try your object on max 6.1 and windows 8. Is there a place I can view some java logs?