Display JSON in routes.js to View

Hi, I’m try to display x value type Json in my routes.js into View, x get from controller.
Can I bring the whole x value into View?

@nolimits4web please help me :slight_smile:

surely i’ve misunderstood, but you have the async method in route that allows you to get back your json data in ajax and use it after into your component or your view.

I’m now using this

app.request.postJSON('/itn/getairways', { orig_code: arrOriginalChecked[0] }, function (data) {
                          
                          for (i = 0; i < data.length; i++) {
                             var strHtml = "<li>";
                             strHtml += "<label class=\"popup-close item-radio item-radio-location item-content airways\">";
                             strHtml += "<input type=\"radio\" name = \"demo-radio\" values="+data[i].Dest_Code+"-"+data[i].dest_name+"/>";
                             strHtml += "<i class=\"icon icon-location\">";
                             strHtml += "<div>"+data[i].Dest_Code+"</div>";
                             strHtml += "</i>";
                             strHtml += "<div class=\"item-inner item-inner-custom\">";
                             strHtml += "<div class=\"item-title\">"+data[i].dest_name+"</div>";
                             strHtml += "</div>";
                             strHtml += "</label>";
                             strHtml += "</li>";
                            
                          }
                          $$("#ulAirwaysDest").html(strHtml);
                      });

Insert directly into <ul> tag. But I don’t think this is the best solution :confused:

the “best” is probably to code it as a component : your request will load the template of your list, and refresh it each time you need to.

http://framework7.io/docs/router-component.html

But i’ve lost your first concern. :s