Can't export mysql table via js script

I can export html table but cant export php table via js. When pressing button it starts download clean excel file(should be table “sanoat”).Whats my problem ? Sorry im newbie. Maybe there is another way to do it ? I know PHPExcel method to get from mysql into excel , but it saves excel in server directory. I need button where you press and it ask where to save excel file with all your table in it.

   <html>
    <body>
<script type="text/javascript" src="tableExport/jquery.js"></script>
<script type="text/javascript" src="tableExport/tableExport.js"></script>
<script type="text/javascript" src="tableExport/jquery.base64.js"></script>
<script type="text/javascript" src="tableExport/html2canvas.js"></script>
<script type="text/javascript" src="tableExport/jspdf/jspdf.js"></script>
<script type="text/javascript" src="tableExport/jspdf/libs/sprintf.js"></script>
<script type="text/javascript" src="tableExport/jspdf/libs/base64.js"></script>
<script type="text/javascript" src="tableExport/jspdf/jspdf.js"></script>
<script type="text/javascript" src="tableExport/jspdf/jspdf.js"></script>
<script type="text/javascript">
    </script>
       <?php
      include ('connect.php');
 echo "<script language='javascript'>
$(document).ready(function(e) {
$('#excel').click(function(e) {
$('sanoat').tableExport({
type: 'excel',
escape: 'false'
});
});
});
</script>
";
$result=mysql_query("SELECT id,name,bank FROM sanoat ORDER BY id");
  $n=mysql_num_rows($result);
echo "<table id='sanoat' border=1>
<tr><th>ID</th><th>name</th><th>bank</th></tr>";
for($i=0;$i<$n;$i++)
 echo 
"<tr><td>",mysql_result($result,$i,id),
"</td><td>",mysql_result($result,$i,name),
"</td><td>",mysql_result($result,$i,bank),
"</td></tr>";
echo "<button id='excel'> Export as Excel </button>"
?>
</table>
</body>
</html>