I'm using the jQuery steps plugin and have this code below. I want the step to change only if the r variable is true
. I did it like this and it is not working for me.
onStepChanging: function(event, currentIndex, newIndex) {
var stepnum = parseInt(currentIndex) + 1;
function getCartProducts(stepnum, callback) {
return $.ajax({
url: path + "/ajax.php?pg=checksurveyrequiredresponses",
data: $("#sendresponses").serialize(),
type: 'POST',
dataType: 'json'
});
}
var theruturn;
getCartProducts(stepnum).done(function(r) {
if (r) {
theruturn = true;
} else {
theruturn = false;
}
}).fail(function(x) {
console.log(x);
});
return theruturn;
}