I am trying to store the results of the return ajax call as: var yValue that is usable in javascript, but the results returning for yValue is always 0.
<head>
$.ajax({
url: 'test2.php',
success: function(data) {
var yValue= data; // data contains value 1;
}
});
alert (yValue);
</head>
The results returned is always zero or null, and when i try to check for the value of data using an alert box, it is always 1.
Even when i used data as the result to store into my array"dynamicdata" that i have created, it will return a value of 0 or NULL:
var globalData = null;
$.ajax({
url: 'test2.php',
async: false,
success: function(data) {
globalData = data;
}
});
var j=j+1;
var CurrentDate1 = new Date((new Date()).getTime())
var hours=CurrentDate1.getHours()
var minutes=CurrentDate1.getMinutes()
var seconds=CurrentDate1.getSeconds()
if (minutes<=9) minutes="0"+minutes;
if (seconds<=9) seconds="0"+seconds;
var timer=hours+":"+minutes+":"+seconds+"";
// remove the first element
dynamicdata.splice(0, 1);
// add a new elemez
dynamicdata.push([timer, globalData]);
Anyone can help?