I have a simple setup that takes a hex value from a color picker converts it to RGB and then sends it to a PHP script from the HTML. The recieving file is not echoing and it is not refreshing either. I probably am doing something wrong but wanted to run it by someone just in case.
Java/Jquery
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
$(document).ready(function() {
var picker = $.farbtastic('#picker');
picker.linkTo(function onColorChange(color) {
var finalcolor=hexToRgb(color);
console.log(finalcolor,"helloworld");
$.post("imagedisplay.php", {var_value: finalcolor});
});
});
RECIEVING PHP
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$hex=$_POST['var_value'];
echo '$hex';
}
?>