Cordova Phonegap OnsenUI未从jquery ajax调用中追加数据
我试图在ajax调用完成后追加一些数据。我可以将数据附加到Phonegap应用程序中的可见页面模板(page1.html),但无法将任何数据附加到其他不可见但位于同一index.html文件中的页面。有没有办法解决这个问题Cordova Phonegap OnsenUI未从jquery ajax调用中追加数据,cordova,onsen-ui,Cordova,Onsen Ui,我试图在ajax调用完成后追加一些数据。我可以将数据附加到Phonegap应用程序中的可见页面模板(page1.html),但无法将任何数据附加到其他不可见但位于同一index.html文件中的页面。有没有办法解决这个问题 $(document).ready(function () { var user_id = 1; $( document).ready(function (){
$(document).ready(function ()
{
var user_id = 1;
$( document).ready(function (){
$.ajax({
type: "GET",
url: "http://xxx-env.elasticbeanstalk.com/api/usersol/user/1",
dataType: 'jsonp',
error: function(){
//alert( 'Unable to load feed, Incorrect path or invalid feed' );
},
success: function(data){
alert(data[0].cortisol);
$("#cort_l_today").replaceWith('<p id="cort_l_today"><span class="numberCircle3" >'+data[0].cort+'</span></p>');
$("#cort_l_today2").replaceWith('<p id="cort_l_today"><span class="numberCircle3" >'+data[0].cort+'</span></p>');
}});
});
});
<ons-template id="page1.html">
<ons-page>
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="menu.toggle()">
<ons-icon icon="ion-navicon-round" size="28px" fixed-width="false" style="color:#fff" ></ons-icon>
</ons-toolbar-button>
</div>
<div class="center">Dashboard</div>
<div class="right">
<ons-toolbar-button>
<ons-icon icon="ion-refresh" fixed-width="false" style="vertical-align: -4px;color:#5e3f3d"></ons-icon>
</ons-toolbar-button>
<ons-toolbar-button>
<ons-icon icon="ion-plus-round" fixed-width="false" style="vertical-align: -4px;color:#5e3f3d" id="camBtn"></ons-icon>
</ons-toolbar-button>
</div>
</ons-toolbar>
<div class="tab-bar tab-bar--top tab-bar--top-border">
<label class="tab-bar__item tab-bar--top-border__item">
<input type="radio" name="top-tab-bar-b" checked="checked">
<button class="tab-bar__button tab-bar--top-border__button">
<ons-icon icon="ion-arrow-graph-up-left" size="28px" fixed-width="false"></ons-icon>
</button>
</label>
</div>
<ons-row style="margin-top: 0px; text-align: center;">
<p style="color: #999; font-size: 13px;">
<div id ="postlist"></div>
<p id="cort_l_today2"></p>
<div id='chart'>
<svg style='height:500px'> </svg>
</div>
</p>
</ons-row>
<ons-row align="center" style="margin-top: 30px; text-align: center;">
<ons-col width="10%">
<div class="Demo">
</div>
</ons-col>
<ons-col>
<ons-row align="center" style="margin-top: 0px; text-align: center;">
<ons-col width="50%">
<div class="numberCircle">
12 </div>
<div class="center" style="font-size:11px;padding-top:15px">Weekly Avg </div>
</ons-col>
<ons-col width="50%">
<div class="numberCircle2">
15%
</div>
<div class="center" style="font-size:11px;padding-top:15px">Weekly Change </div>
</ons-col>
</ons-row>
</ons-col>
<ons-col width="10%">
<div class="Demo">
</div>
</ons-col>
</ons-row>
</ons-page>
</ons-template>
<ons-template id="page2.html">
<ons-page>
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="menu.toggle()">
<ons-icon icon="ion-navicon-round" size="28px" fixed-width="false" style="color:#fff"></ons-icon>
</ons-toolbar-button>
</div>
<div class="center">Activity</div>
<div class="right">
<ons-toolbar-button>
<ons-icon icon="ion-refresh" fixed-width="false" style="vertical-align: -4px;color:#5e3f3d"></ons-icon>
</ons-toolbar-button>
<ons-toolbar-button>
<ons-icon icon="ion-plus-round" fixed-width="false" style="vertical-align: -4px;color:#5e3f3d"></ons-icon>
</ons-toolbar-button>
</div>
</ons-toolbar>
<div class="tab-bar tab-bar--top tab-bar--top-border">
<label class="tab-bar__item tab-bar--top-border__item">
<input type="radio" name="top-tab-bar-b" checked="checked">
<button class="tab-bar__button tab-bar--top-border__button">
<ons-icon icon="ion-stats-bars" size="28px" fixed-width="false"></ons-icon>
</button>
</label>
</div>
<ons-row style="margin-top: 20px; text-align: center;">
<ons-col>
<p style="color: #999; width:100%">
<p style="font-size:15px;color:#999"> <h2 style="color:#999">Wednesday</h2></p>
<p style="font-size:15px"> <h5 style="color:#c5c5c5"><ons-icon icon="ion-calendar" size="38px" fixed-width="false"></ons-icon> 11th Dec 2015</h5></p>
<p id="cort_l_today"><span class="numberCircle3" ></span></p>
<p style="font-size:15px;padding-top:20px"> </p>
<p style="margin-left:5%;margin-right:5%">
<ons-row align="center" style="margin-top: 0px; text-align: center;">
<ons-col width="40%">
<button class="button--large--cta" >Previous</button>
</ons-col>
<ons-col width="20%">
</ons-col>
<ons-col width="40%">
<button class="button--large--cta" >Next</button></p>
</ons-col>
</ons-row>
</p>
<p style="background:#e15500;padding-top:15px;padding-bottom:15px;color:#fff;font-size:14px" align="center">Todays activities</p>
<p style="background:#fff;border-bottom:1px solid #e3e3e3;padding-top:15px;padding-bottom:15px;color:#fff;font-size:14px" align="center">dasdada</p>
<p style="background:#fff;border-bottom:1px solid #e3e3e3;padding-top:15px;padding-bottom:15px;color:#fff;font-size:14px" align="center">dasdadad</p>
<p style="background:#e15500;padding-top:15px;padding-bottom:15px;color:#fff;font-size:14px" align="center">Past 7 days activities</p>
<p style="background:#fff;border-bottom:1px solid #e3e3e3;padding-top:15px;padding-bottom:15px;color:#fff;font-size:14px" align="center">dasdada</p>
</ons-col>
</ons-row>
</ons-page>
</ons-template>
$(文档).ready(函数()
{
var user_id=1;
$(文档).ready(函数(){
$.ajax({
键入:“获取”,
url:“http://xxx-env.elasticbeanstalk.com/api/usersol/user/1",
数据类型:“jsonp”,
错误:函数(){
//警报(“无法加载提要、路径不正确或提要无效”);
},
成功:功能(数据){
警报(数据[0]。皮质醇);
$(“#cort_l_today”)。替换为(''+数据[0]。cort+'
');
$(“#cort_l_today 2”).replace为(“”+数据[0]。cort+”
);
}});
});
});
仪表板
12
每周平均值
15%
每周变动
活动
2015年12月11日
今天的活动
dasdada
dasdadad
过去7天的活动
dasdada
我不确定,但可能是因为DOM在使用您的双重/相同id插入时遇到了问题:
今天的科尔图
插入后,DOM将遇到麻烦。;-)所以你应该改变这一点,改为去上课