javascript - script to call other php page not working -
need help, button not working, report generator button main page not calling report.php page, in chrome, i've checked network tab under developer tools , im not getting activity/response when click report generator button, below main php page:
<script type="text/javascript"> $(document).ready(function(){ $("#retrievelist").on('click',function() { var xid = $('#xid').val(); var date = $('#date').val(); $.post('retrieve_test.php',{xid:xid, date:date}, function(data){ $("#results").html(data); }); return false; }); $("#deletefromdb").click(function() { if (confirm("are sure want delete?")) var id = $('input[name=checkbox]:checked').map(function() { return $(this).val(); }).get(); $.post('delete_test.php',{id:id}, function(data){ $("#result").html(data); }); return false; }); }); $("#report").on('click',function() { var date = $('#date').val(); $.post('report.php',{date:date}, function(data){ $("#results").html(data); }); return false; }); </script> <form id="form2" name="form2" method="post" action=""> <table width="741" border="0" align="center"> <tr> <th colspan="9" align="center" style="font-size:14px" scope="col">xid, name:<span> <select name="xid" id="xid"> <option value="aaa">aaa</option> <option value="bbb">bbb</option> <option value="" selected="selected">please select...</option> </select> </span><span style="font-size:14px"> <label for="date">date:</label> <input type="text" name="date" id="date" size="8"/> </span></th> </tr> <tr> <th colspan="9" scope="col"> </th> </tr> <tr> <th colspan="9" scope="col"> <div align="center"> <input name="action" type="button" id="retrievelist" value="retrieve list" /> <input name="action" type="button" id="deletefromdb" value="delete db" /> <input name="clear" type="reset" id="clear" value="clear" onclick="window.location.reload()" /> <input name="action" type="button" id="report" value="report generator" /> </div> <label for="clear"></label> <div align="center"></div></th> </tr> </table> </form> <div id="results"> </div>
while here report.php page code:
<?php require 'include/db_open.php'; $date = $_post['date']; $sql="select trouble_type_priority, category_1, category_2, status, count (*) total tbl_main resolved_date = '$date' group trouble_type_priority, category_1, category_2, status"; $mydata = mysql_query($sql)or die(mysql_error()); echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th colspan='3' align='center'>ticket bucket</th> <th colspan='3' align='center'>status</th> </tr> <tr> <th width='auto' align='center'>severity</th> <th width='auto' align='center'>category 2</th> <th width='auto' align='center'>category 3</th> <th width='auto' align='center'>resolved</th> <th width='auto' align='center'>re-assigned</th> <th width='auto' align='center'>grand total</th> </tr>"; while($info = mysql_fetch_array($mydata)) { echo"<tr>"; echo "<td align='center'>" . $info['trouble_type_priority'] . "</td>"; echo "<td align='center'>" . $info['category_1'] . "</td>"; echo "<td align='center'>" . $info['category_2'] . "</td>"; echo "<td align='center'>" . $info['status'] . "</td>"; echo "</tr>"; } echo "</table>"; include 'include/db_close.php'; ?>
it looks code have setting onclick
event report button outside of $(document).ready(...)
function. right now, javascript execute before rest of page ready , @ point there no report button add event it.
i think, may issue. try moving $("#report").on('click', ...)
$(document).ready(...)
callback function.
Comments
Post a Comment