-1
我使用名爲Avactis的購物車。它返回給我很少的「信息標籤」用於我的前端。他們看起來像這樣:在JSON數據中使用PHP函數
<?php ProductSmImage();?>
<?php ProductName();?>
我想在我的一些產品中使用敏捷轉盤腳本。我想使用小圖片,產品名稱,產品替代文字和產品鏈接。
的JSON數據文件是這樣的:
[{
"content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='images/banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
"content_button": "<div class='thumb'><img src='images/f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
}]
而在前端的腳本是這樣的:
<script>
// Code used for "Flavor 2" example (above)
$.getJSON("agile_carousel/agile_carousel_data.php", function(data) {
$(document).ready(function(){
$("#flavor_2").agile_carousel({
// required settings
carousel_data: data,
carousel_outer_height: 330,
carousel_height: 230,
slide_height: 230,
carousel_outer_width: 480,
slide_width: 480,
// end required settings
transition_type: "fade",
transition_time: 600,
timer: 3000,
continuous_scrolling: true,
control_set_1: "numbered_buttons,previous_button,
... (continues on same line)... pause_button,next_button",
control_set_2: "content_buttons",
change_on_hover: "content_buttons"
});
});
});
所以,我想,以取代第一HREF與圖像的src和等等。
我認爲這與JSON編碼有關,但我不是程序員(顯然),並且需要知道在哪裏編寫代碼以將標記轉換爲JSON數據,如果您可以給我一小部分樣本要遵循的代碼,我會永遠感激。
謝謝!
我假設尾隨的「]」實際上在JSON文件中? – Hubro 2012-03-27 15:03:27
你可以發佈創建這個JSON字符串的代碼嗎?即時猜測你想要修改?它不容易理解你想要做什麼......用你想要它做什麼語言...... – ManseUK 2012-03-27 15:03:27
¿你如何得到這個json? ¿通過PHP或jQuery的? – Patroklo 2012-03-27 15:03:54