weixin_33691817 2017-03-03 18:58 采纳率: 0%
浏览 7

形成ajax问题

I have a form that throws 500 error with the following lines on the trace

send @ jquery.js:9536
ajax @ jquery.js:9143
(anonymous) @ practice:177
dispatch @ jquery.js:5201
elemData.handle @ jquery.js:5009

Form is

 <form id = 'sendForm' enctype='multipart/form-data'>
    <div class="form-group">
        <input  type = 'text' style = 'display: none;' name = 'idExer'  id = 'idExer'>
        <label class="control-label">Sube tu archivo de Python para probar el código
        </label>
        <input  type="file" name="solution" id="solution">
    </div>
    <input type="submit" class="btn common-btn ">Enviar código</input>
</form>

And ajax call is

$('#sendForm').submit(function(e){
    var form = document.querySelector('#sendForm');
    var formData = new FormData(form);

    e.preventDefault();
    $.ajax({
        crossOrigin: true,
        type:'POST',
        url: '/student/practice/'+ $("#idExer").val(),
        data: formData,
        processData:false,
        contentType:false,
        success: function (data) {

        },
        error: function(response) {
            console.log(response.status + " " + response.statusText);
        }
    });
});

The router is like

router.post('/practice/:id', function(req, res, next){
//stuff here
}

This is on an Express app and the form is on the same route as the post one. The form has one file upload and a hidden input that passes as a parameter on the ajax call.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 宇视监控服务器无法登录
    • ¥15 PADS Logic 原理图
    • ¥15 PADS Logic 图标
    • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
    • ¥20 气象站点数据求取中~
    • ¥15 如何获取APP内弹出的网址链接
    • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
    • ¥50 STM32单片机传感器读取错误
    • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
    • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)