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.

<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">
      include ('connect.php');
 echo "<script language='javascript'>
$(document).ready(function(e) {
$('#excel').click(function(e) {
type: 'excel',
escape: 'false'
$result=mysql_query("SELECT id,name,bank FROM sanoat ORDER BY id");
echo "<table id='sanoat' border=1>
echo "<button id='excel'> Export as Excel </button>"