语言

Menu
Sites
Language
I want to retrieve data from website to mobile application.I want the data to be display in my own page

Hi,

    I want to retrieve data from online site and display it in my own page.I have done this but not working.

$('#sp1').click(function() {
    $.getJSON('http://apibeta.yourstory.com/v1/site/YOURSTORY/articles', function(jd) {
        window.location = jd[0].permalink;
    });
      
    });

 

Please help me

Thanks and regards

Mohit Kumar

 

响应

7 回复
Vikram

Hi,

I think it is ok, please refert to below code,

<head>
<script>   
    $(document).ready(function() {
        $("button").click(function(){
        	$.getJSON('http://apibeta.yourstory.com/v1/site/YOURSTORY/articles', function(jd) {
                window.location = jd[0].permalink;             
            });         
        });
    });   
</script>
</head>
<body>
    <button>get json data</button>
    <p></p>
</body>

 

Palitsyna

Hello,

your code works well. Just wait for a while, and data will be displayed on your screen. If not, check your internet connection and be sure that you have added internet privilege and access tag into your config.xml file.

Palitsyna

Hello,

just FYI, here you cam find more information about getJSON() method: 

http://www.w3schools.com/jquery/ajax_getjson.asp

http://api.jquery.com/jquery.getjson/

Both links contain examples and useful iformation about this method.

AVSukhov

Hello,

For this purpose you can use XMLHttpRequest:

https://developer.tizen.org/development/api-references/web-application?redirect=https%3A//developer.tizen.org/dev-guide/2.3.1/org.tizen.web.apireference/html/web_api_reference.htm

Seoghyun Kang

Hello,

 

Please do not forget to add the following codes.

<tizen:privilege name="http://tizen.org/privilege/internet"/>     
<access origin="*" subdomains="true"></access> 

 

Seoghyun Kang

As AVSukhov's comments, you can use the XMLHttpRequest.

 

Please refer the following codes.

var xmlhttp, xmlDoc, dataItem;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", XML_ADDRESS, false);
xmlhttp.onreadystatechange = function() {
    var weatherInfo, tempInfo;
    if (xmlhttp.readyState === 4) {
        if (xmlhttp.status === 200) {
            xmlDoc = xmlhttp.responseXML;
            dataItem = xmlDoc.getElementsByTagName('item');
            if (dataItem.length > 0) {
               // TODO
            } 
            xmlhttp = null;
        }
    }
};
xmlhttp.send();

 

Marco Buettner

You forget to write an specific code for his problem ... He (topic creator) is not able to create a solution by a "general" code ... =)