In my jQuery script I use the get function to extract data from a PHP page called "external.php". The data extracted is a simple path to an image (e.g. images/house.jpg). I need to use this path to specify the css value background-image of a div, whose class is "fullpage".
This is my faulty script: when I try to insert data in my script, the image doesn't appear.
$(document).ready(function(){
$.get('external.php', function(data){
$('.fullpage').css('background-image', 'url(' + data + ')');
});
});
The script works if I simply switch "data" with the name of a variable whose value is my manually inserted path, so the problem is: how do I insert correctly the data value into the .css() method?
Thank you
Ricardo was right: I used console.log(data) as Jason P suggested and it showed me an html tag that didn't have to be in the php code. When I appended the result the tag didn't appear being part of an html structure, but logging helped me seeing it. Thank you!