我有一個getjson
調用,我想通過它的一些項目。我想知道我可以多次調用這個getjson
並傳遞它們的值,比如書,筆,紙......如果這些商品在銷售中顯示在不同的iframe中,如下所示(例如,我想檢查10個項目if他們正在銷售)?如何多次調用getJson並在完成第一個傳遞的項目後傳遞值?
目前,我的代碼只處理一個項目,但我希望它處理10個項目並顯示出售的項目。
此外,如果用戶在頁面中,而且用戶不必重新加載頁面,我希望每10分鐘執行一次商品清單檢查過程。你們能告訴我如何做到這一點嗎?
<script src="http://anyorigin.com/jquery-1.4.2.min.js"></script>
<script>
$.getJSON('http://anyorigin.com/get?url=http://www.awebsite.com/item=book/&callback=?', function(data){
var siteContents = data.contents;
//writes to textarea
//document.myform.outputtext.value = siteContents;
var n=siteContents.search("This item is not on sale");
alert("value of n:"+n);
if(n=-1) {
alert("item book is on sale. n:"+n);
$('#ItemBookWrapper').show();
//if the passed item is on sale display that item in a iframe if its not on sale go //to next item. so at
} else {
alert("item:book is not on sale");
}
});
</script>
</head>
<body>
<div id="ItemBookWrapper" style="display:none">
<iframe src='http://www.awebsite.com/item=book' height=200 width=200 style='border: none;'></iframe>
</div>
<br>
謝謝tadiou。但是,我如何可以調用getjson 10次(在頁面加載時)並通過這10個項目,以便過濾掉那些正在銷售並顯示它們? – user1788736 2013-05-09 03:23:08