티스토리 뷰

728x90
반응형
Controller
 public JsonResult currentWeather(string regionCode)
 {
     return Json( new { icon = "weather.png", regionName = "서울", etc = "35", weather = "맑음" } );
 }

*.js
                listeners: {
                    painted: function () {
                        var thisObj = this;
                        Ext.Ajax.request({
                            url: currentWeather,
                            params: { regionCode: '11B101010' },
                            method: 'post',
                            success: function (response) {                                
                                var data = Ext.JSON.decode(response.responseText.trim());
                                tpl = new Ext.XTemplate(
                                "<div>",
                                "   <div style='float:left;'><img src='../../resources/icons/{icon}' style='width:140px; height:140px' alt='날씨 아이콘' /></div>",
                                "   <div style='float:right;'><table><tr><td style='text-align:center'>{regionName}</td></tr><tr><td style='font-size:40px; font-weight:bold;'>{etc}℃</td></tr><tr><td style='font-size:30px; font-weight:bold; text-align:right;'>{weather}</td></tr></table></div>",
                                "</div>");
                                thisObj.setTpl(tpl);
                                thisObj.setData(data);                                
                            }
                        });
                    }
                }



728x90
반응형