언어 설정

Menu
Sites
Language
Tizen Wearable SDK -- How to Send HTTP Requests

Trying to invoke the following AJAX call in the AJAX method below to perform a simple post following a button click. However, I'm seeing that I'm unable to do so on my Samsung Gear 2 application. My watch has a sim card with data, and I know apps such as Yelp and Milk have direct internet access capability. I have "<tizen:privilege name="http://tizen.org/privilege/internet"/>" permissions in config.xml. Could someone tell me what else I'm missing?

var dta = '{"messages":[{"body":"hello world!"}]}';

   $.ajax({

          url: postURL,
          type: "POST",
          dataType: "json",
          contentType: "application/json",
          data: dta,
          cache: false,
          beforeSend: function (xhr) {
            /////   Authorization header////////
              xhr.setRequestHeader("Authorization", "OAuth 2JyFoheRlMqzbGODPAckvBh6OLM");
          },
          success: function (data) {
           console.log("Success send");
          },
          error: function (jqXHR, textStatus, errorThrown) {
           console.log("error send");
          }
      }).fail(function () {
       console.log("Success fail");
      });

 

Edited by: Jay ried on 29 4월, 2015

Responses

6 댓글
Marco Buettner

only Gear S can establish internet connection without SAP/paired Android device...

Jay ried
Hi Marco I have the gear S not the 2.... when the onclick event occurs I don't see the forumm submission on the web service. Is there some other configuration that im missing?
Marco Buettner

You miss paired Android device and SAP. You cannot open internet resources by Gear (2) - except the Gear S. You need to transfer your request via SAP to the Android device and the result back from Android to Gear

Jay ried

Hi Marco,

Attempting to clarify futher....I actually have the Samsung Gear S watch, not the Samsung Gear 2 watch...I have the Samsung Gear S watch with a valid Sim Card....In my code, I'm using the AJAX submit above, and I have network permissions under config.xml.

My problem is the form data is not posted and I assume it's because my app is not connecting to the internet. Is there any other configuration that I'm missing? I tried Googling and coundnt find any sample code that shows the configuration process to send data over the Gear S's data network.

Marco Buettner

Ah ok,

I think you have forgot to allow the access to any page or specific url on the config.xml :)

Goto the policy tab of the config.xml and add on the access table

And write * if you want access to very web resource or the specific url :)

AVSukhov

Hello,

Try to use XMLHttpRequest:

var xmlhttp = null;
xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == xmlhttp.DONE){
alert(xmlhttp.responseText);
}
else{
alert(xmlhttp.statusText);
}
};
xmlhttp.onerror = function(e){
alert("onerror: " + xmlhttp.statusText);
};

xmlhttp.open("GET", yourUrl);

xmlhttp.send();

and config.xml:

<access origin="*" subdomains="true"></access>
<tizen:allow-navigation>yourUrl</tizen:allow-navigation>
<tizen:privilege name="http://tizen.org/privilege/internet"/>