Не происходит запись в DB (javascript -> php)

235
20 марта 2017, 10:04

Поле ставки:

<input type="text" name="u_stavka" size="3" value="10">

Кнопка которая рандомно генерирует числа:

<script type="text/javascript">
 (. . . много кода . . .)
var button = document.getElementById('button');
    button.onclick = function() {
      var resultL  = diceL.rollL();
      var resultR  = diceR.rollR();
      var status   = document.getElementById('status');
      if (parseInt(resultL) > parseInt(resultR)) {
          document.getElementById("status").innerText = "Выиграл";
         function dice_win(){
         ajax.exec({action : 'games.php', mode: 'dice_win', u_stavka: u_stavka, id: id});
          }
    }
      else if (parseInt(resultL) < parseInt(resultR)) {
         document.getElementById("status").innerText = "Проиграл";
         function dice_lose(){
         ajax.exec({action : 'games.php', mode: 'dice_lose', u_stavka: u_stavka, id: id});
    }
}
      else {
         document.getElementById("status").innerText = "НИЧЬЯ";
         }
         printNumber(resultL),printnumberR(resultR),status;
    };
</script>

в условие вписываю функции(function dice_win() и function dice_lose()) которая, должна зачислять/снимать количество очком указных в input name="u_stavka"

И сам файл файл games.php

$mode     = (string) $this->request['mode'];
$id       = (int) $this->request['id']; 
$points   = (int) $this->request['points']; 
$u_stavka = (string) @$this->request['u_stavka'];
switch($mode)
{       
    case 'dice_win':
$u_stavka    = (string) @$this->request['u_stavka'];
        DB()->query("UPDATE user SET points = $points + $u_stavka WHERE id = $id LIMIT 1");
    break;
    case 'dice_lose':
$u_stavka    = (string) @$this->request['u_stavka'];
        DB()->query("UPDATE user SET points = $points - $u_stavka WHERE id = $id LIMIT 1");
    break;
}

но списание/зачисление очков так и не происходит. Подскажите что я не правильно делаю?

READ ALSO
Перемещение по DIV&#39;ам с помощью кнопок на JavaScript

Перемещение по DIV'ам с помощью кнопок на JavaScript

Интересует возможность перемещения по элементам DIV с помощью клавиатуры (кнопок: вверх, вниз, вправо, влево)К примеру, при нажатии кнопки вниз,...

387
I need to access a variable from a .getCurrentPosition() function [требует правки]

I need to access a variable from a .getCurrentPosition() function [требует правки]

Here is the code and i want for example to access the latitudw variable outside of this function and for example set to its value

276