0
jQuery中,我讀網絡地址從XML使用追加到jQuery Mobile的列表視圖:本地主機前置到網頁地址
<script>
var coupons = [];
var names = [];
var li = "<li><a href='#' rel='external'></a></li>";
$.ajax({
type: "GET",
url: "data/xml/markers.xml",
dataType: "xml",
success: parseXml
});
function parseXml(xml) {
var counter = 1;
$(xml).find("marker").each(function() {
name = $(this).find("name").text();
web = $(this).find("web").text();
names[counter] = name;
//web += "/coupons/"
//web += name.toString();
coupons[counter] = web;
$("#couponlinks").append(li);
alert(couponlinks[counter]);
counter++;
});
$("#datalist li a").each(function (index) {
this.text = names[index];
alert(coupons[index]);
this.href = coupons[index]; // this appends the web address plus the localhost
});
}
</script>
實際的網絡地址獲取與本地主機前綴,並且不指向實際的地址。 即wwww.thewebsite.com與web變量前置的localhost一起出來。
我不明白這種行爲。謝謝你的幫助。
*另外,當我追加'li'時,它顯示爲一個普通鏈接而不是fancier $ .mobile listview項目。
* Stackoverflow將不允許本地主機條款,所以我將lclhost取消。 TY
工作就像一個魅力。非常感謝你。 – sum1nil