0
我試圖創建一個基於掀起了插件的動態內容股利。默認情況下,插件會獲取幻燈片對象並在逗號處分解它。每個逗號後面的每個字符串都是分開的。但是,當通過AJAX返回值時,它將被解釋爲一個長字符串,而不是被分解。我怎樣才能讓jQuery將它分成多個字符串?
Ajax的:被返回
$.ajax({
url: 'backend/index.php',
data: {'check':'true'},
type: 'POST',
async: false,
success: function(data) {
var carousel,
el,
i,
page,
slides = [ data ];
}
};
當前數據:
echo "
'<strong>Swipe</strong> to know more >>><br>Or scroll down for <em>Lorem Ipsum</em>',
'1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.',
'2. A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.',
'3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.'
";
exit();
幻燈片的默認例如:
slides = [
'<strong>Swipe</strong> to know more >>><br>Or scroll down for <em>Lorem Ipsum</em>',
'1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.',
'2. A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.',
'3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.'
];
作爲參考,這是使用SwipeView插件發現這裏:http://cubiq.org/swipeview
爲您的字符串添加一個分隔符並將其分隔在分隔符(例如|和data.split(「|」))上,或者將數據作爲有效的JSON返回並將數據類型更改爲JSON –
您的原因不返回一個JSON對象開始是? – epascarello
'async:false' - 爲什麼,哦爲什麼??? :) – Andreas