I have followin pages
- index.php
- importdata.php
Im trying to use ajax importing a csv file into MySql I used dsome exapmples on the net but still wont work index.php
the Script file in the beginning:
$(document).ready(function(){
$("#but_import").click(function() {
var formData = new FormData($("#import_form"));
$.ajax({
url:"importData.php",
data:formData,
type:'POST',
success:function(response)
{
var resp = $.trim(response);
$("#output").html(resp);
}else[
$("#output").html("Error");
});
});
});
The HTML after the script:
<html>
<head>
<title>Import CSV file data to the MySQL using PHP</title>
</head>
<body>
<form id="import_form" method="post" action="" enctype="multipart/form-data" >
<table width="100%">
<tr>
<td style="width: 58px">
<input type='file' name="score_file" id="score_file">
</td>
</tr>
<tr>
<td colspan="2" >
<input type="button" id="but_import" name="but_import" value="Import File"></td>
</tr>
</table>
</form>
<table style="width: 100%">
<tr>
<td id="output"> </td>
</tr>
</table>
</body>