我已經寫了下面的代碼來解析和顯示一個xml文件 - 與動態創建的xml文件一起工作正常 - 但對於一些bizzare原因,它不會讀取本地文件或直接從我的服務器上的xml文件!錯誤每一次 - 不能爲我的生活工作出爲什麼!xml解析器不工作?
任何意見將非常歡迎!
function testPay() {
$.ajax({
type: "POST",
url: "http://fb.mobilechilli.com/chillifacebook.xml",
dataType: "xml",
error: errorMsg,
success: function(mml) {
alert("here");
$(mml).find("album").each(function()
{
var titleA = $(this).find('productDescription').text();
if(titleA.length > 13){
var title = titleA.substring(0,10) +"..";}
else if(titleA.length < 13){title = titleA; }
var artistA = $(this).find('artist').text();
if(artistA.length > 13){
var artist = artistA.substring(0,10)+ "..";
}
else if(artistA.length < 13){artist = artistA; }
var artwork = $(this).find('artwork').text();
var price = "Buy £" + $(this).find('price').text();
var mediaItem = $(this).find('mediaItem').text();
var artwork = $(this).find('artwork').text();
var chargeCode = $(this).find('chargecode').text();
var productCode = $(this).find('productCode').text();
var listItem = $('<div class="mediaBlock"><form action="https://wpg.dialogue.net/pfiwidget/ButtonHandler" method="post" id="pfi_form'+mediaItem+'" name="pfi_form" target="thisframe"><input type="hidden" name="transactionRequest" id="pfi_transactionRequest" value="' + chargeCode + '"><input type="hidden" name="productCode" id="pfi_productCode" value="' +productCode+'"><input type="hidden" name="productDescription" id="pfi_productDescription" value="'+title+'"><input type="hidden" name="category" id="pfi_category" value="MUSIC"><input name="notificationUrl" type="hidden" value="http://fb.mobilechilli.com/chilli_shop/index-shop_xml.php" /><input type="hidden" value="http://www.facebook.com/pages/Chilli-Music/145522908841649/?affiliate=facebook_order" name="fulfilmentUrl"><input type="hidden" value="http://www.facebook.com/ChilliMusicStore?v=app_152948274779752" name="returnUrl"><input type="hidden" name="serviceDeliveryMessage" id="pfi_serviceDeliveryMessage" value="https://www.mobilechilli.com/mobile-downloads-uk/thanks.php"><input type="hidden" value="chilli_GB_Facebook" name="brandName"><div class="promoImg floL"><a name="pfi_form'+mediaItem+'" class="overlayLink" href="#data"><img src="'+artwork+'" width="82" height="85" alt="'+artist+'-'+title+' " /></a><div class="promoContent"><h2 class="red">'+artist+'</h2><h2>'+title+'</h2><div class="buyBtn"><span><a name="pfi_form'+mediaItem+'" class="overlayLink" href="#data">'+price+'</a> </div></div></div></form>');
$(".trackRow").append(listItem);
hideLoading();
});
}});
function errorMsg() {
alert("error getting xml feed");
}
};
「http:// fb.mobilechilli.com」與請求它的頁面處於同一個域嗎? – 2011-12-14 15:18:39