What i want is to get the color value from one JavaScript section into another php file which acts as a css file. I saw some example with ajax however they do not work, although the .done and .always say the data is send. So here is the script part and the color value:
var jCell = '#aabbcc';
$(document).ready(function (){
$.ajax({
url: "view/stylesheet/supercharge.css",
data: {cell: jCell},
type: "POST",
async: false })
.done(function(cell) { console.log("success: "+ jCell); })
.fail(function() { console.log("error"); })
.always(function() { console.log("complete"); })
});
Here is the php file(acting as css) and it should get the value with $_post however it doesn't:
<?php header("Content-type: text/css; charset: UTF-8"); ?>
<?php
$menuColor = '#121212';
$headerColor = $_POST['cell'];
$bodyColor = '#fffaaa';
?>
#header {
background-color: <?=$headerColor; ?>;
}
Any suggestions?
Thanks.
done
fires, so as far as I can see this is working. Sounds like you're expecting something to happen other than theconsole.log()
call. – MrCode Jun 10 '13 at 15:40