我遇到JSONP调用问题, 我需要多次调用javascript函数
在示例中,html页面仅适用于最后一个名为not for all 3的函数。
我怎么解决?
(如果我设置了超时间隔,页面工作,但我不想要那个解决方案)
感谢
在代码
下面HTML PAGE
**
<!-- start codice che va aggiunto al box ADV -->
<script type="text/javascript" src="http://localhost/nativeadv/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://localhost/nativeadv/client_location/visualizzaJsonHome.js"></script>
<div class="contenutoHomeNativeAdv" id="contenutoHomeNativeAdvCirioHome"></div>
<script type="text/javascript">getAdv("CirioHome");</script>
<!-- end codice che va aggiunto al box ADV -->
<!-- end codice che va aggiunto al box ADV -->
<div class="contenutoHomeNativeAdv" id="contenutoHomeNativeAdvcoca1"></div>
<script type="text/javascript">getAdv("coca1");
</script>
<div class="contenutoHomeNativeAdv" id="contenutoHomeNativeAdvkinder_client"></div>
<script type="text/javascript">getAdv("kinder_client");
** 错误是:
JS PAGE
function getAdv(nick){
nick_cliente=nick;
URLJSONP = LINK_BASE_URL+URL_JSONCB;
$.ajax({
url: URLJSONP,
type: "GET",
dataType: "jsonp"
});
}
function clAdv(json){
var adv_stamp;
ricercaAdv=json;
dettAdv='';
for(var i=0;i<ricercaAdv["adv"].length;i++){
if(ricercaAdv["adv"][i].id==id_adv){
dettAdv+='<div class="nativeadvtitlecontent" ><h1>'+ricercaAdv["adv"][i].Titolo+ '</h1></div>';
dettAdv+='<div class="nativeadvdatacontent" >'+ricercaAdv["adv"][i].Datainserimento+ '</div>';
}
}
document.getElementById("contenutoContentNativeAdv").innerHTML=dettAdv;
}