php - Why does this javascript won't work? -
i ask voting box included in our website files. cause there seemed problem this. whenever click "click here vote". nothing happens, not have idea why since not java codings. i'd include codes of guys can take at.
this voting box: http://i.stack.imgur.com/3lv8s.png
so code of going click it:
if(isset($_session['user'])) { odbc_exec($mssql, 'use [account_dbf]'); $votepoints = odbc_exec($mssql, 'select votepoints [account_tbl] account=\''.mssql_escape_string($_session['user']).'\''); echo 'current vote points: <b><span id="currvp">'.odbc_result($votepoints, 'votepoints').'</span></b><br/><br/>'; echo '<span id="takeitem"></span>'; echo '<a href="javascript:votetab();"><b>click here vote!</b></a>'; } else { echo '<b>you must login before can vote!</b>'; } this votetab(); function:
function votetab() { $.ajax({ url: 'ajax.php?a=vote', type: 'get', datatype: 'php', timeout: 1000, success: function(response){ $(".boxcontent").html(response); } }); this ajax:vote function:
if($_get['a'] == 'vote') { // vote box odbc_exec($mssql, 'use [account_dbf]'); $userselect = odbc_exec($mssql, 'select * [account_tbl] account=\''.mssql_escape_string($_session['user']).'\''); $user = odbc_fetch_array($userselect); $diff1 = diff($user['lastvote1']); $diff2 = diff($user['lastvote2']); $diff3 = diff($user['lastvote3']); $votedtoday = 0; if($diff1['hours'] < 12) $votedtoday = $votedtoday + 1; if($diff2['hours'] < 12) $votedtoday = $votedtoday + 1; if($diff3['hours'] < 12) $votedtoday = $votedtoday + 1; echo 'username: <b>'.$user['account'].'</b><br/><br/>'; echo 'current vote points: <b><span id="vpoints">'.$user['votepoints'].'</span></b><br/><br/>'; echo 'you can vote <b><span id="vtoday"> '.(3 - $votedtoday).' </span></b> more times today.<br/><br/>'; if($diff1['hours'] >= 12 || $diff2['hours'] >= 12 || $diff3['hours'] >= 12) { if(isset($_get['submit'])) { if($_get['submit'] == 1) { if($diff1['hours'] >= 12) { odbc_exec($mssql, 'update [account_tbl] set votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_get['submit']).'=\''.date('d.m.y h:i:s').'\' account=\''.mssql_escape_string($_session['user']).'\''); } } elseif($_get['submit'] == 2) { if($diff2['hours'] >= 12) { odbc_exec($mssql, 'update [account_tbl] set votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_get['submit']).'=\''.date('d.m.y h:i:s').'\' account=\''.mssql_escape_string($_session['user']).'\''); } } elseif($_get['submit'] == 3) { if($diff3['hours'] >= 12) { odbc_exec($mssql, 'update [account_tbl] set votepoints=votepoints+\'1\', lastvote'.mssql_escape_string($_get['submit']).'=\''.date('d.m.y h:i:s').'\' account=\''.mssql_escape_string($_session['user']).'\''); } } } echo 'you gain 1 vote point each topsite.<br/>after voting able choose free gift!<br/>follow instructions vote 3 topsites.<br/><br/><div id="topsite" style="text-align: center;">'; if($diff1['hours'] >= 12) { // top of games echo '<img src="img/tog.gif" /><br/><br/>'; echo '<span id="votetext"><a onclick="vote(1, '.$diff2['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist1.'" target="_blank">click here continue!</a></span>'; } elseif($diff2['hours'] >= 12 ) { // xtreme top 100 echo '<img src="img/xtop100.jpg" /><br/><br/>'; echo '<span id="votetext"><a onclick="vote(2, '.$diff3['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist2.'" target="_blank">click here continue!</a></span>'; } elseif($diff3['hours'] >= 12) { // g top 100 echo '<img src="img/gtop100.jpg" /><br/><br/>'; echo '<span id="votetext"><a onclick="vote(3, 0, \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist3.'" target="_blank">click here continue!</a></span>'; } echo '</div>'; } else { echo '<a href="javascript:voteitemtab();">choose item!</a>'; } } /* vote box end */ i need answers of how work.
you're missing closing curl brace on function.
function votetab() { $.ajax({ url: 'ajax.php?a=vote', type: 'get', datatype: 'php', timeout: 1000, success: function(response){ $(".boxcontent").html(response); } }); }
Comments
Post a Comment