changing css properties through ajax, does not work?
I'm trying to change the background color of a div, by using ajax (to retrieve the user's color from the database). Here is the code:
$.ajax({type: "POST", data: {id: id}, url: "actions/css.php", success: function(result) {
$('.panel').animate({left: 350, width:700});
$('.data').html(id);
//background color
$('.panel').css('background-color','#' + result.bgcolor);
});
But the color doesn't change, I know the JSON has been retrieved开发者_JAVA百科 by checking firebug, but it looks like a client side thing.
EDIT:
$('#mainTitle').html(result.title);
If this doesn't seem to work, I guess it might be JSON compatibility or something.
On your $.ajax call you should specify the the dataType to json
$.ajax({dataType: 'json'...})
精彩评论