I'm new to JavaScript and haven't been able to cross a tutorial that explains the following situation.
The goal I'm trying to achieve here is that I will get the output of my jQuery function and place it inside of a variable. More explicit, I want to pull data from a MySQL table and place the data into a variable.
Then I will use that variable will then be used inside of another variable which is a calculation.
The function (I know the following code doesn't work, but I'm not sure what's proper):
var sliderValue = function() {
$.ajax({
url: "select.php",
type: "GET",
success: function(result) {
// alert(result);
return result;
}
});
});
Using the variable (ignore the totalCost variable):
var startValue = ((sliderValue - totalCost) / totalCost ) * 100;
I know the variable calculation above works when I use a basic variable such as var totalCost = "52";
.
Thanks for the help in advance.