我正在使用volusion商店創建一個網站。我希望產品能夠顯示在產品頁面上,並且我正在自定義代碼。我已經創建了api,即標準導出,我只需要使用ajax將該產品的詳細信息提取到頁面。那麼我該如何實現呢?對於第一種類型,我創建了帶.xml擴展名的API,例如, https:///dataport/dl/Generic/Products.xml,然後顯示數據,我也可以獲取該數據,但對於第二種類型的URL,例如, HTTP:///net/WebService.aspx登錄= & EncryptedPassword = & EDI_Name =通用\產品& SELECT_Columns = p.ProductID,p.ProductName,pe.Photo_AltText,pe.Photo_SubText,pe.PhotoURL_Large,pe.PhotoURL_Small, pe.Price_SubText,pe.Price_SubText_Short,pe.ProductPrice,pe.ProductPrice_Name 我無法使用ajax獲取數據。雖然第一次使用這個URL它顯示數據,但是當我刷新它然後它不顯示。問題與Volusion API
下面我分享我的代碼,請審視一下,幫我解決這個問題,
<script>
$(document).ready(function(){
$.ajax({
type: "POST",
url: "http://<domainname.com>/net/WebService.aspx?Login=<username>&EncryptedPassword=<password>&EDI_Name=Generic\Products&SELECT_Columns=p.ProductID,p.ProductName,pe.Photo_AltText,pe.Photo_SubText,pe.PhotoURL_Large,pe.PhotoURL_Small,pe.Price_SubText,pe.Price_SubText_Short,pe.ProductPrice,pe.ProductPrice_Name",
dataType: "xml",
success: function(result) {
alert(result);
parseXml(data);
}
});
});
function parseXml(data) {
var id;
var code;
var name;
$(data).find('Products').each(function(){
$(this).find("ProductCode").each(function() {
code = $(this).text();
});
$(this).find("ProductID").each(function(){
id = $(this).text();
});
$(this).find("ProductName").each(function(){
name = $(this).text();
});
$('.col-md-6').append(code +"<br />"+ id +"<br />"+ name);
});
}
</script>
<div id='getresult'>
Api code will refelect here
<div class="container">
<div class="row">
<div class="col-md-6"></div>
</div>
</div>
</div>
永遠不會在任何客戶端代碼中使用Webservice登錄電子郵件地址和加密密碼。如果你這樣做,你不妨將它發佈在這裏,因爲沒有什麼區別。你幾乎給任何人免費通過你的網站。不要做! – user357034
我沒有看到,謝謝指出。 同樣,我給你一個通過JQuery使用你的API的例子,這是不安全的,我太累了,我想不出爲什麼不說,所以我說我不認爲它會工作。 如果你需要的信息,我會得到它,如果你與我聯繫,我將刪除從我的答案j查詢部分,因爲它是最終用戶的安全風險,而不是PCI兼容......但如果你嘗試更清楚地解釋你想要完成什麼,如果它是產品頁面上的產品信息,我可能會幫助你獲得沒有API的數據.... –