I am trying to store the variable associated with a given button, that can then be used as one of the parameters in the data field of an ajax PUT. I have the following, but can't figure out why its not storing the value of ratio:
HTML
<li class="imgly-controls-item-square">SQUARE</li>
<li class="imgly-controls-item-16-9">16-9</li>
<li class="imgly-controls-item-9-16">9-16</li>
jQuery
$(".imgly-controls-item-square").click(function () {
var ratio = "square";
alert(ratio);
});
$(".imgly-controls-item-16-9").click(function () {
var ratio = "16-9";
alert(ratio);
});
$(".imgly-controls-item-9-16").click(function () {
var ratio = "9-16";
alert(ratio);
});
//Will store value of selected image crop orientation, that can then be appended to ajax data parameter below
var imageOrientation = ratio;
Current JSFiddle: LINK
Uncaught ReferenceError: dataUrl is not defined. And check the scope ofratio.ratiois local to whatever handler you declare it indataUrlinvar saveImage = encodeURIComponent(dataUrl);anddatainurl: urlLocation + data,