I have a program that needs to get some fresh data every time a button is pushed, then use that data to continue execution. I have read through a ton of suggestions bit none seem to work so i must be doing something wrong. This is the calling function:
function _onSpin(iNumBettingLines,iCoin,iCurBet) {
if(iCurBet > s_aSession["iMoney"]){
_dieError("INVALID BET: "+iCurBet+",money:"+s_aSession["iMoney"]);
return;
}
makeNextResult(s_aSession["user_name"],s_aSession["coin_bet"],s_aSession["coin_bet"]);
responce_string = getNextResults();
_Result = [];
var res_string = parseResult(response_string);
var incomming = res_string.split("#");
var this_ln;
var x = 0;
var bFreespin = 0;
var bBonus = 0;
var reel_pos;
var bet_amt = 25;
for(i=0;i<=incomming.length-1;i++){
this_ln=incomming[i].split(",");
_Result[i]=this_ln;
}
}
_initSettings();
var rls;
for(a=0;a<=_Result.length-1;a++){
if(_Result[0][0]==bet_amt){
rls = _Result[0][3];
break;
}
}
if(rls!="undefined"){
reel_pos =rls.split("*");
for(a=0;a<reel_pos.length;a++){
fs = reel_pos[a].split("%");
_aFinalSymbols[a] = new Array();
_aFinalSymbols[a][0] = fs[0];
_aFinalSymbols[a][1] = fs[1];
_aFinalSymbols[a][2] = fs[2];
_aFinalSymbols[a][3] = fs[3];
_aFinalSymbols[a][4] = fs[4];
}
}
if(_Result[0][1]==0){
var str = JSON.stringify(_aFinalSymbols);
return "res=true&win=false&pattern="+JSON.stringify(_aFinalSymbols)+"&money="+s_aSession["iMoney"]+"&freespin="+s_aSession["iTotFreeSpin"]+"&bonus=false&bonus_prize=-1";
}
aRet = stuffResults(bet_amt);
var str = JSON.stringify(_aFinalSymbols);
return "res=true&win=true&pattern="+_aFinalSymbols+"&win_lines="+JSON.stringify(aRet)+"&money="+s_aSession["iMoney"]+
"&tot_win="+iTotWin+"&freespin="+s_aSession["iTotFreeSpin"]+"&bonus="+s_aSession["bBonus"]+"&bonus_prize="+iPrizeReceived+"&cash="+s_aSession["iSlotCash"] ;
}
notice the line "responce_string = getNextResults();"
Here is the code for getNextResults()
function getNextResults(){
foo(function(result) {
return result;
});
}
And finally the foo function
function foo(result) {
var url = "http://server678.net/ExampleService.asmx";
$.support.cors = true;
$.ajax({
type: "POST",
url: url,
contentType: "text/xml",
dataType: "xml",
data: _SoaMessage,
processData: true,
success: function (data, status, req) {
result(req.responseText);
}
});
}
The program calls getnextResult but instead of waining for the function to return a value it just blows right through it and response string is always undefined.
What I have tried:
I have been researching this for days and nothing seems to work. Please help.