Languages

Menu
Sites
Language
Ajax request Canceled in Tizen's emulator, but not in browser

I currently have an error with my tizen emulator when I try to contact a `webservice` through `$.getJSON`.

I have a button, when I click on it, I get the JSON from a `webservice`, simple as that. On my computer browser, this works perfectly, but when I run the code as an app on Tizen's emulator (gear), the `GET` method returns : (canceled)
`Request cancelled`.

Here's the code (main.js):

    $(window).load(function(){document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back")
            tizen.application.getCurrentApplication().exit();
    });
    $('.button').click(function(){
        callWebService();//Calls webservice
        return false;
    });

    function callWebService(){
        //Works on desktop's Chrome
        $.getJSON( "https:// www . googleapis . com/freebase/v1/text/en/bob_dylan", function( data ) {
              $('#ol_home_products').html(data.result);
            })
            .fail(function( err ) {
                //Never called
                console.log( err );
            });
    }
    });

I can see the cancel error in Networks's tab, but nothing shows up in Console.
I don't know where the problem is in Tizen gear emulator, the code works perfectly in browser.

Thanks.

Edited by: Armand LOT on 04 Jun, 2015
View Selected Answer

Responses

6 Replies
Marco Buettner

Did you setup the config.xml? You have to setup the privileg "http://www.tizen.org/privileg/internet" and the access domain

Armand LOT

I did, I still got the error.

 

That's the only privilege I've set.

Marco Buettner

share your config.xml

Armand LOT

Here it is :

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/myApp" version="1.0.0" viewmodes="maximized">
    <tizen:application id="jVqvRz7h1V.myApp" package="jVqvRz7h1V" required_version="2.2"/>
    <content src="index.html"/>
    <feature name="http://tizen.org/feature/screen.size.all"/>
    <icon src="icon.png"/>
    <name>myApp</name>
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
</widget>
Mark as answer
Marco Buettner

Like I wrote above, you forgot to define the access domain ;) Try this config.xml

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/myApp" version="1.0.0" viewmodes="maximized">
    <tizen:application id="jVqvRz7h1V.myApp" package="jVqvRz7h1V" required_version="2.2"/>
    <access origin="*" subdomains="true"/>
    <content src="index.html"/>
    <feature name="http://tizen.org/feature/screen.size.all"/>
    <icon src="icon.png"/>
    <name>myApp</name>
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
</widget>

 

Armand LOT

Oh right I'm sorry, thank you a lot !

I guess I need to read a bit more about permissions and config.xml on Tizen =/