I am setting up a function where clicking a button sets an image to a fullscreen background etc. It gets the image_name from mysql, I can alert the filename so I know it is returning the correct information.
If I hard code the image_name it works perfectly, but if I return it directly from the db via ajax call it doesn't. I am completely lost as to why? Can anyone suggest where I might be going wrong.
$.ajax({
type: "POST",
url: "ajax.php",
data: { value: value, id: id },
success: function(image_name){
$('.click').hide(); //This will hide the button specified in html
$('body').css({"background-image":"url(../article_images/"+image_name+")",
"background-repeat":"no-repeat",
"background-position":"center center",
"background-attachment":"fixed",
"-webkit-background-size":"cover",
"-moz-background-size":"cover",
"-o-background-size":"cover",
"background-size":"cover"});
}
});