Return value is null without debug
Hi all,I am trying to call a php page in javascript and i am returning a variable.
my code is
function temponclick(x, y,name) {
$.ajax({
url: 'temperature.php',
type: 'POST',
data: { name:name,x:x,y:y},
success:function(response){
temp1=response;
}
});
return temp1;
}
temp1 is displaying correctly when i debug the code, but when i run the code without debugging then temp1 is null for first time and second time if i call the same function then first value is displaying in the second call.
please tell me where i am doing mistake.