I have spent a whole evening on this; the code sends the colours to a php page where the image is modified and currently saved to the same folder as the code. When I am up and running I want to save the modified image into a sub folder.
The problem I have is I want the image to display on the same code as the colour picker.
I have been trying some " success:" code @James_Hibbard provided a few years back which works OK with some different code but not this:
var colorInputs = $("input[type='color']");
colorInputs.on("change", function(){
$(this).next().text(this.value)
});
$("form").on("submit", function(e){
e.preventDefault();
$.ajax({
url: 'output.php',
type: 'POST',
data: {
color1: colorInputs[0].value,
color2: colorInputs[1].value,
},
success: function(image_url) {
var img = new Image();
img.src = image_url;
img.onload = function(){
$("#new_image").html(img);}
},
})
.done(function(data) {
console.log(data);
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
colorInputs.trigger("change");
I am echoing out the image name in the php after the image is completed: echo $new_image;
There are no errors in the web console:
Array modify_colours.php:54:
(
[color1] => #000000
[color2] => #000000
)
hat1.jpg
complete modify_colours.php:61:11