Tizen Wearable SDK — How to Send HTTP Requests

Tizen Wearable SDK — How to Send HTTP Requests

BY 29 Apr 2015 SDK & IDE

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”);
      });

 

Written by