php - Javascript not working in AJAX response -
below code ajax response page. have added onclick event table row , written javascript code handle it. javascript code doesn't work.is wrong way of coding or there problem in code. suggest me simple solution
<?php echo '<script type=\"text/javascript\"> function clicked(){ alert("i alert box!"); } </script>'; $q = $_get['q']; include 'db_connect.php'; $sql="select name,address,mobile,email,pan,tan client name = '$q'"; $sql_bill="select clientname,financialyear,receiptno,amount,ddate,type,chequeno,category billing clientname = '$q'"; $sql_total="select sum(amount) totalamount billing"; $result = mysql_query($sql); $result_bill = mysql_query($sql_bill); $result_total = mysql_query($sql_total); $total= mysql_fetch_array($result_total); echo "<h4><b>client details</b></h4><table align='center' border='2'> <tr> <th>name</th> <th>address</th> <th>mobile</th> <th>email</th> <th>pan</th> <th>vat tin</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['address'] . "</td>"; echo "<td>" . $row['mobile'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['pan'] . "</td>"; echo "<td>" . $row['tan'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "<h4><b>payment received details</b></h4><table align='center' border='2'> <tr> <th>client name</th> <th>financial year</th> <th>receipt no</th> <th>date</th> <th>type</th> <th>chequeno</th> <th>category</th> <th>amount</th> </tr>"; while($row = mysql_fetch_array($result_bill)) { echo "<tr onclick=\"clicked()\">"; echo "<td>" . $row['clientname'] . "</td>"; echo "<td>" . $row['financialyear'] . "</td>"; echo "<td>" . $row['receiptno'] . "</td>"; echo "<td>" . $row['ddate'] . "</td>"; echo "<td>" . $row['type'] . "</td>"; echo "<td>" . $row['chequeno'] . "</td>"; echo "<td>" . $row['category'] . "</td>"; echo "<td>" . $row['amount'] . "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan=7>total</td>"; echo "<td>".$total['totalamount']. "</td>"; echo "</tr>"; echo "</table>"; ?>
try instead of script code:
echo <<<eod <script type="text/javascript"> function clicked(){ alert("i alert box!"); } </script> eod;
Comments
Post a Comment