We have moved to a new Sailfish OS Forum. Please start new discussions there.
7

How do you use javascript in apps?

asked 2016-06-07 13:51:13 +0300

roham gravatar image

I need a native Sailfish app to report my position to a server. I have done this as a web page through a browser but as soon as the screen goes black the reporting stops.

To my understanding you can use javascript in QML in apps. How do you do that? All I've seen yet is c++. How do i insert the following in QML?


navigator.geolocation.watchPosition(reportPosition);

function reportPosition(position) {

var url = "http://www.exemple.com/reportserver.cgi";
var positionAsString = "lon=" + position.coords.longitude + 
    "&lat=" + position.coords.latitude;
var request = new XMLHttpRequest();
request.open("POST", url);
request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
request.send(msg);
}
 
edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
8

answered 2016-06-07 14:39:38 +0300

phklrz gravatar image

Hello, you can find the answer here : http://doc.qt.io/qt-5/qtqml-javascript-expressions.html

edit flag offensive delete publish link more

Comments

2

Thank you very much. That is my missing manual.

roham ( 2016-06-07 15:36:34 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2016-06-07 13:51:13 +0300

Seen: 280 times

Last updated: Jun 07 '16