Taske new javascript support and XMLHttpRequest

473 views
Skip to first unread message

InfX

unread,
Aug 3, 2012, 2:43:13 PM8/3/12
to tas...@googlegroups.com
The javascript support page mentions "JSON and XMLHTTPRequest are also directly available from the JavaScript code". I've been thinking "hmm, i can find some use for this", considering stuff such as price alerts in my Android notification bar and similar kind of things. For the sake of testing i've attempted to run the script listed below, and it didn't really work, failing with "exception 101". Some quick Googling provided an assumption exception 101 is likely to be a result of a denied cross site scripting access attempt.

Now, if that's indeed that case, with the script running in tasker is, essentially, being local, does it means the XMLHTTPRequest is practically useless ?

Any ideas on how to circumvent it ?


function foo()
{
    var http = new XMLHttpRequest();
    http.open("GET","http://www.google.com/",false);
    http.send();
    return(http.responseXML);
}

try
{   
    alert("Hello World");
    alert("Foo: "+foo());
}
catch(e)
{
    alert("oops");
    alert(e);
    alert(e.message);
}

InfX

unread,
Aug 10, 2012, 5:32:46 PM8/10/12
to tas...@googlegroups.com
Anyone ? :-(

Pent

unread,
Aug 11, 2012, 4:06:03 AM8/11/12
to Tasker
I'll check that when I get the chance.

Pent

Pent

unread,
Aug 11, 2012, 9:15:44 AM8/11/12
to Tasker
> Now, if that's indeed that case, with the script running in tasker is,
> essentially, being local, does it means the XMLHTTPRequest is practically
> useless ?

I've specified a file:// base url for the next update. Android seems
to allow the cross site requests then.

Also:

>     var http = new XMLHttpRequest();
>     http.open("GET","http://www.google.com/",false);
>     http.send();
>     return(http.responseXML);

That should be http.responseText I think.

I used:

function foo()
{
var http = new XMLHttpRequest();
http.open("GET","http://www.google.com",false);
http.send();
return(http.responseText);
}

try
{
flash("Foo: "+foo());
}
catch(e)
{
flash(e.message);
}

InfX

unread,
Aug 11, 2012, 3:02:00 PM8/11/12
to tas...@googlegroups.com
Thanks.

About responseText with responseXML, the responseXML is a DOM object, i really doubt it is is going to be available on an html data. The responseText is just a raw string with data. In any case, this is unrelated to the issue.

Thanks again for helping :)
Reply all
Reply to author
Forward
Message has been deleted
0 new messages