Discussion Board

Results 1 to 10 of 10

Threaded View

  1. #1
    Registered User VituchoInfonor's Avatar
    Join Date
    Jul 2011
    Posts
    20
    Greettins.
    I am trying to persist some data that i get in the web page using an xhr request.
    The problem it's seems to be that no data is being recorded to the phone as in the next launch you can not retrieve the info.
    • I am using the "Nokia Web Developer Environment 1.2.0" currently to developt the app and testing with the preview emulator that comes within.
    • Using the widget.preferences.setItem(key,data) and widget.preferences.setItem(data) as the doc says

    I paste the javascript along with html code to see what i am doing more precisely


    HTML CODE:
    Code:
     	<input type="button" onclick="getJSON();" value="Get JSON"/><br/>
    	<input type="button" onclick="getIt();" value="retrieve data from pref"/>
    JAVASCRIPT CODE:

    Code:
    function getJSON()
    {
    	var xhr;
    	xhr = new XMLHttpRequest();
    	xhr.open("GET","http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&country=US", true);
    	xhr.onreadystatechange = function(){
    		if (xhr.readyState == 4) {
    			if (xhr.status == 200) {
    				document.getElementById('test').innerHTML= "<b>"+ xhr.responseText + "</b><br/>";;
    				widget.preferences.setItem("REG001",xhr.responseText);
    			}
    			else {
    				document.getElementById('test').innerHTML= "Error code " + xhr.status;
    			}
    		}
    	}
        xhr.send(null);
    }
    
    function getIt ()
    {
    	document.getElementById('test').innerHTML = document.getElementById('test').innerHTML + "<br/>" + widget.preferences.getItem("REG001");
    }
    Well thanks for advance.
    Grettins!.
    Víc

    P.D: This wasn't actually tested on a real phone, just on the emulator. BUT it obviously must work, or don't?
    Last edited by VituchoInfonor; 2011-08-09 at 02:19. Reason: Additonal info added

Similar Threads

  1. Replies: 1
    Last Post: 2010-02-23, 14:16
  2. Problem with persisting data into the rms
    By ionutdavid_eu in forum Mobile Java General
    Replies: 2
    Last Post: 2008-01-11, 08:03
  3. Problem with persisting data into the rms
    By ionutdavid_eu in forum Mobile Java General
    Replies: 3
    Last Post: 2008-01-10, 13:15
  4. Problem with persisting data into the RecordStore
    By ionutdavid_eu in forum Mobile Java General
    Replies: 1
    Last Post: 2007-12-19, 12:34
  5. Persisting object trees to RMS
    By jose.moreira in forum Mobile Java General
    Replies: 1
    Last Post: 2006-08-08, 02:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved