Languages

Menu
Sites
Language
cross origin request

In my application I make a cross origin ajax request, it works well in Tizen's browser, but when I package it as web application, the cross origin request can't work.

Could any expert tell me why?

The following is my code:

 

  var url = "";//this is assigned a domain supports cross domain access according to HTML5 specification.

  var client = new XMLHttpRequest();

  client.open("GET", url)

  client.setRequestHeader("Accept-Language", 'en-us');

  client.onreadystatechange = function() { alert("succeed"); }

  client.send();
Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

4 Replies
Lakshmi Grandhi
Hi jason ji, In Emulator ajax call are working, add one more paramter as true specifying it as asynchronous client.open("GET", url, true). Below code works try it. var client = new XMLHttpRequest(); client.open("GET", url, true) client.setRequestHeader("Accept-Language", 'en-us'); client.onreadystatechange = function() { alert("succeed"); } client.send();
jason ji
Thanks for your patient answer! But I have taken your advice, and tested it on both emulator and a real Tizen device. It can't work when the variable url contains a domain name. I have used the webkit inspector record the network log, every request is recorded, but there's no url no http header, only an empty record. It's weird. This forum can upload images, otherwise I would upload a screenshot of inspector.
jason ji
http://stackoverflow.com/questions/15105698/cross-origin-request-in-web-application
Lakshmi Grandhi
Hi jason, Is it working by giving privilages for subdomains as mentioned in stackoveflow or