added ajax and finished bet logic