I wrote a parser, which downloads a HTML file and convert it as normal text. And finally flash it as a Toast. For that, I used Javascript, because I think, it is a bit faster than the simple Task option.
The code works, but I Can't found any way to download the html file directly from the JS code. So I tried to use JQuery and wrote this code part to download the HTML and load it to a Global Tasker variable:
$.get('http://example.com/index.html', function( data ){
setGlobal('%Data', data);
}, 'html')
And I selected JQuery from the Libraries at the Javascriptlet page from the magnifying glass's list. But it not works... :(
Is the JQuery works in Tasker? Or just the Tasker based codes (like setGlobal) not works between a JQuery code part?
What's wrong?
Thanks for Your answer!
--
Dan
Nobody Can help me?
Now I am using a shell and the wget command, but the JQuery would be nice for other operations too. Is it workable?
Thanks again!
I want to parse a json file. But I download it from the internet. Yes, I Can use the HTTP Get and the %HTTPD variable, but I want to do this via a single JS code.
Now, I am using shell, like this:
shell('wget http://path/to.json',3);
But if the JQuery is workable it would be better than this way. Because the JQuery has a $.get "function", but I Can't use it, because the Tasker's Javascript Can't use the JQuery which in the Libraries part of the Javascriptlet.
So... My question is why not works the JQuery?
The code works, but I Can't found any way to download the html file directly from the JS code.
So I tried to use JQuery and wrote this code part to download the HTML and load it to a Global Tasker variable:
$.get('http://example.com/index.html', function( data ){
setGlobal('%Data', data);
}, 'html')
try
{catch(error)
{
alert(error);
}
Hi!
> You can use this: https://developer.mozilla.org/de/docs/Web/API/XMLHttpRequest
Yes, I tried it, but not worked. I think it is an ajax feature too which not works below Tasker javascript.
> Use try/catch to get an error message:
>
> try
> {
>
> $.get('http://example.com/index.html', function( data ){setGlobal('%Data', data);}, 'html')
> }
> catch(error)
> {
> alert(error);
> }
I tried it, but not worked, and nothing shown at the error output. But the global %Data is blank.
Ps: I think it isn't alert, it is flash.
The global variable is just a test.
> You do not need a global variable. Just parse the result of your http-request directly with the JSON-object: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON
Yes, I know that, but it is just a part of a function. I want to parse the data at a second part of the code.
Thanks!
var url = "http://date.jsontest.com";
var http = new XMLHttpRequest();
http.open("GET", url, false);
http.send();
if (http.status == 200)
{
var json = JSON.parse(http.responseText);
alert("Now it is " + json.time);
}
else
{
alert("HTTP-Error...");
}
Many thanks, it works!
I think, I missed the .send... :)
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/MHP46EEVq5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.