0

i am a Java Developer and i need to create a SIMPLE app, as i need this to run into ios & Android i decided to try it using lungoJS, my main problem is that i dont know much JavaScript.. :( well i have created the prototipe of the app using lungo, but now i need to fill a list with the response (on Json) from my server. I saw in lungos api the function that is used to get a Json request. looks like this:

var url = "http://localhos:8080/myService";
var data = {id: 25, length: 50};
var parseResponse = function(result){
//Do something
};

Lungo.Service.json(url, data, parseResponse, "json");

//Another example
var result = Lungo.Service.json(url, "id=25&len=50", null, "json");

my http request is indexed from 1 to 4 so for each element would be "www.myapp.com/api/1" "www.myapp.com/api/2" .... my question is, hoy could i get the answer (json) of my request and how do i select items for example if i only want the "name" or "surname"... thanks, hope some1 could help me :)

Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
Mendas
  • 31
  • 3

1 Answers1

0

I solved my problem long time ago, i will share it:


    function some_function(callback) {



        var my_number = $$.get('http://app.com/applications/3.json',{ }, function(api) {
                                    obj=api;
                                    template="{{#name}}\
                                                    \
                                                 {{/name}}";
                                    html=Mustache.render(template,obj);
                                    $$('section#main article#main-article').html(html); //Painting Json obtained on my HTML
                                }
                                );
     ;
        callback(my_number);
    }

    // call the function
    some_function(function(num) {
        // this anonymous function will run when the
        // callback is called
        console.log("callback called! " + num);
    });

This code uses the obtained Json to Prototype HTML, useful to load images or data from server and not stored on local.

BR, Kike

Mendas
  • 31
  • 3