I'm trying to add a dynamic background using the .css() property of jQuery. The background URL is provided through AJAX:
function requestbg(cusa) {
$.ajax({
url: 'api/bg.php',
type: 'GET',
data: {id: cusa},
success: function(response) {
if(response != "") {
var url = response;
$("body").css("background-url", url);
console.log(response);
}
}
});
}
When changing background-url to background-color, it does work. Weird, because in the console I log the response, and it does return a URL. Figured there might be a space somewhere, checked it multiple times but nothing.
Does anybody know why this would not work?