Languages

Menu
Sites
Language
I don't get response from specific url using xmlhttprequest

Hi I tried to get the response from strava.com but it doesn't return nothing, the status for this is 0. When I tried to get response from google.com it works. the strangest about this, is it worked yesterday but now it doesnt work anymore, also when I try to navigate strava.com with opera it works, I dont understand.

My privilege:

 <tizen:allow-navigation>*</tizen:allow-navigation>
    <tizen:application id="00M0dII0NW.Basic" package="00M0dII0NW" required_version="2.2"/>
    <content src="index.html"/>
    <tizen:content-security-policy>*</tizen:content-security-policy>
    <tizen:content-security-policy-report-only>*</tizen:content-security-policy-report-only>
    
     <tizen:privilege name="http://tizen.org/privilege/internet"/>

my Code:

var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200) {
   
    //this.responseText
   
    alert(this.responseText);
    }
  };
  xhttp.open("GET", "https://www.strava.com/login", true);

  //xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhttp.send();
   }

 

I also noticed that the domParser doesn't work in my app or did I do something wrong?

function getToken(html){
var parser = new DOMParser();
var parsedHtml = parser.parseFromString(html, 'text/html');
var x = parsedHtml.getElementsByName("csrf-token")[0].content;
return x;
}

 

 
it works great in my browser but not on tizen 2.2 wearable, is there any other way to get the csrf token I tried regex but it matches more than csrf token only.
 
I appriceate any help 
Thank you

 

 

Edited by: houssain elbou on 06 Dec, 2018

Responses

3 Replies
Armaan-Ul- Islam

# Defining external access Policy may be required to access network. According to the W3C Access Requests Policy (WARP), you cannot access external network resources by default. If you require access to an external network resource, you must request network resource permissions for the Web application using the Policy in the config.xml file.

 

<access origin="*" subdomains="true"/>                         // For All resources
 //OR
<access origin="yourdomain.com" subdomains="true"/>           // For specific resource

 

# Add internet access privilege for your Tizen application in the config.xml file.Internet Privilege allows the application to access the Internet.

<tizen:privilege name="tizen.org/privilege/internet"/>

Check out this response on Stack Overflow Forum.

houssain elbou

Thanks brother That's exactly what I needed!

<access origin="*" subdomains="true"/>    

But still I find it strange why it worked before whitout this policy..

 

also I fixed the getToken without DOMparser I used regex for it. I've read that DOMparser is an browser future that's maybe why it didn' work.

houssain elbou

Hi Armaan,

It's been a while since I came back to tizen development.  I still have some issues getting the response from strava.com/login, the status for this is still 0 from other website such as google or stackoverflow I get the response but not for this. It works before and after some months not anymore.

I added all the privillege but still nothing

 

Hope you have a solution for me because its getting very frustrating for me.

 

thank you