dongyan7950 2018-06-19 14:00
浏览 212

使用Ajax和PHP导入csv导入csv到mysql,而不是上传文件

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">&nbsp;</td>
    </tr>
</table>
</body>

  • 写回答

2条回答

  • dongtingxiao4697 2018-06-19 15:08
    关注

    What error does it put out.

    Also look at the spelling of "importdata.php".

    In the ajax you have "url:"importData.php"" but at the start you said you have "importdata.php".

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器