I have two functions:
function ajaxtakesource4(callback){
var ajaxRequest; // The variable that makes Ajax possible!
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange =function(){
if(ajaxRequest.readyState == 4 &&ajaxRequest.status==200){
var sourcetest = ajaxRequest.responseText;
callback(sourcetest);
}
}
ajaxRequest.open("POST", "takesource4.php", true);
ajaxRequest.send(null);
}
The second one, called ajaxtakesource3
is similar to ajaxtakesource4
.
Then i have
function run() {
var somous4 , somous3 ;
ajaxtakesource4(function(sourcetest){
var somous4=sourcetest;
});
ajaxtakesource3(function(sourcetest){
var somous3=sourcetest;
});
var result= soumous3+somous4;
alert (result);
}
I call the above the function on button click:
<div id="run">
<button id="button_run" class="button" onclick="run()">Run</button>
</div>
The problem is that i can use the variable somous4
only in the function ajaxtakesource4
and the same the somous3
variable.
I would like to use them in run function.