我想將我在PHP文件中的數組傳遞給另一個用java腳本編寫的文件。 這是我的數組:從PHP文件傳遞數組到JS文件
$pictures = array(
"1" => array("caption" => "1920x1200px", "tag" => "wallpaper", "link" => "#"),
);
在我的Java腳本文件,這是我想打電話給數組的地方: (在地方,他們應是我寫的TAG,鏈接和標題中的代碼。 Sry基因,如果這是一個愚蠢的問題,但正如你看到的,我不知道PHP和Java Script的想法)
F.helpers.title = {
beforeShow: function (opts) {
var text = F.current.title,
type = opts.type,
title,
target;
if (!isString(text) || $.trim(text) === '') {
return;
}
title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap"><h1>' + text + '</h1><p>CAPTION</p></div><div class="fancybox-title fancydownload" ><a href="LINK"><img src="../../../slider/img/download.png" alt=""/></a></div><div class="fancybox-title fancytag"><h2>TAG</h2></div>');
switch (type) {
case 'inside':
target = F.skin;
break;
case 'outside':
target = F.wrap;
break;
case 'over':
target = F.inner;
break;
default: // 'float'
target = F.skin;
title
.appendTo('body')
.width(title.width()) //This helps for some browsers
.wrapInner('<span class="child"></span>');
//Increase bottom margin so this title will also fit into viewport
F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')));
break;
}
if (opts.position === 'top') {
title.prependTo(target);
} else {
title.appendTo(target);
}
}
};
AJAX不是必需的。 –
如果圖像真的是靜態的,則爲true,這完全會使PHP完全無法使用,並直接在JavaScript中使用PHP的數組內容。那麼首先使用PHP就沒有意義了。 – dbf
是的,因爲JavaScript非常擅長例如訪問數據庫。 Yeesh。 –