$(document).ready(function() {
initfun();
console.log("initalized !");
});
function initfun() {
var basepath = document.location.href + "/wp-content/themes/breviter/assets/tmbdapicalls.py";
$.ajax({
type: "get",
url: "http://127.0.0.1:5000/guestSuggestion",
datatype: "json",
success: function(response) {
var output = response;
//console.log(JSON.stringify(output));
var json = JSON.parse(output);
var backpostimage = "https://image.tmdb.org/t/p/w600" + json["results"][0]["backdrop_path"];
console.log(backpostimage);
document.getElementById("page-canvas").style = 'background-image: ' + backpostimage + ';background-repeat: no-repeat; background-size:100% 100%;'
}
})
}
我使用上面的代碼來設置元件的CSS背景,但由於某種原因我無法設置背景圖像paramater Ajax加載圖像,其他PARAMATERS被成功地作爲設定下面如何使用關於文檔準備
<div id="page-canvas" class="page-wrapper" style="background-repeat: no-repeat; background-size: 100% 100%;">
在'網址圍住圖像()' – Niladri