I am creating Stratego.
(the error is farther down)
so i am creating the map when the page is loadet whit:
turn = true;
komboType = "2kombo";
GameOpsetning = [];
GameOpsetningEnemy = [];
$(document).ready(function() {
createmap();
}
and then i do some console log to make sure it works..
function createmap () {
if (!GameStarted) {
console.log("GameOpsetning" + GameOpsetning);
if(GetSetup(Gameid)){
console.log("GameOpsetning1" + GameOpsetning);
}
else
{
console.log("GetSetup : error");
}
and here the error comes, it will open the file "game.php" whit no error. but it will not do eny thing in side the post/funcion. It will not do the alert or the if or console.log?
function GetSetup (Gameid) {
console.log("GameOpsetning3: " + GameOpsetning);
if ($.post("game.php", { gameid: Gameid }, function(data) {
alert(data);
var data2 = JSON.stringify(data);
alert(data2);
//var json = $.parseJSON(data);
if (data2.status2 && data2.status2 != "false") {
console.log("data.game: " + JSON.stringify(data.game));
GameOpsetning = JSON.stringify(data.game);
GameOpsetningEnemy = JSON.stringify(data.enemygame);
komboType = data.type;
turn = data.turn;
console.log("GameOpsetning5: " + GameOpsetning);
return true;
}
else
{
console.log("error: ");
return false;
}
})){
console.log("post: done");
}else{
console.log("post: error");
}
console.log("GameOpsetning4: " + GameOpsetning);
}
the console output:
GameOpsetning
GameOpsetning3:
post: done
GameOpsetning4:
GetSetup : error
there is no console errors and the page is return JSON
and it have try ed to do like:
console.log("GameOpsetning" + GameOpsetning);
GetSetup(Gameid);
console.log("GameOpsetning1" + GameOpsetning);
if (CheckGame()) {
then the console log is:
GameOpsetning
GameOpsetning1
GameOpsetning3:
post: done
GameOpsetning4:
GetSetup : error
Sorry for my bad English.