언어 설정

Menu
Sites
Language
XMLHttpRequest failed

I am trying to send request to my server from tizen web app. But it always failed. I added jquery, angularjs, TAU and other required lib in the project. what is the problem ?

Code =>>>>

  var xhr = new XMLHttpRequest();
   xhr.open('get', url, true);
   xhr.responseType = 'json';
   xhr.onload = function() {
    var status = xhr.status;
    if (status == 200) {
     
    } else {
    
    }
   };
   xhr.send();
  };

Responses

7 댓글
Marco Buettner

I think you forgot to setup your config.xml

 

https://developer.tizen.org/forums/web-application-development/accessing-files-remote-server

Yuvraj Coder

Checked that. 

Iqbal Hossain

Hi~

Give these access in your config.xml

<access origin="http://xyz.com" subdomains="true"></access>
<access origin="http://abc.com" subdomains="true"></access>
<access origin="http://pqr.com" subdomains="true"></access>
<access origin="*" subdomains="true"></access>

Also add this

<feature name="http://tizen.org/feature/network.internet"/>

I will suggest you get the server response as string and parse it as json after receiving it. 

Hope it will work. 

-Thanks

Yuvraj Coder

Could you plz tell me detail about json parsing ? 

Iqbal Hossain

Okay....Try like this. Parse the json formatted text in the js as JSON. 

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
  if (xhttp.this == 4 && this.status == 200) {
    var data = JSON.parse(xhttp.responseText);
  }
};
xhttp.open("GET", URL, true);
xhttp.send();

Let me know if it works. 

-Thanks.

Yuvraj Coder

thanks bro.. 
how can i parse the json and showing it on ui using tau? can you tell me?

Iqbal Hossain

you can get a lot resources related to TAU. If you face any problem then please create a separate thread for that. 
And if your problem (this), mark the best answer please. 

-Thank you.