我從圖像標記中獲取src屬性,並通過ajax調用將其發佈到我的數據庫,然後用它來形成一個XML文件。我真的需要擺脫這種形象的道路,似乎很難在如何做到這一點。嘗試使用encodeURIComponent,但沒有多少運氣。以下是我的代碼。謝謝你的幫助!試圖在通過ajax發佈到數據庫時轉義URI。我究竟做錯了什麼?
$('.drag-elem').each(function() {
var xml = '<clother><id>' + $(this).children('img').attr('class') +
'</id><title>' + $(this).children('img').attr('alt') + '</title><z-index>' +
$(this).css('z-index') + '</z-index><top>' + $(this).css('top') +
'</top><left>' + $(this).css('left') + '</left><file>' +
encodeURIComponent($(this).children('img').attr('src')) +
'</file></clother>';
});
是什麼,輸出什麼樣子? – Joe
輸出將是這個。正如你可以從節點看到IMG的網址是不是很XML友好 '<?XML版本= 「1.0」?> 產品5316 琥珀母老虎燈罩 355px 113px http://www.domain.com/images/thumb/phpThumb.php?src=http://www.domain.com/uploads/products/712SP_GLD.jpg&w=95&h=98&q = 90&far = C&bg = FFFFFF ' –
從哪裏輸出? PHP還是JS? – Dor