du7979 2019-03-30 15:04
浏览 90

如何在jquery serialize()中为ajax请求包含input type =“file”?

I'm creating an application that has a form with all types of inputs... My problem is when I'm using serialize() it doesn't include the input type file. so how do I send the file to the backend (PHP) using serialize()? And also I don't want to use FormData(). If there is any way please help me...

//register.php

$.ajax({
    url: "ajax/user.ajax.php",
    type: "post",
    dataType: "JSON",
    data: {
            formData: $('#registrationForm').serialize()
        },
    success: function(response) {
       console.log(response);               
    },
});



 //user.ajax.php
   <?php
      require_once (__DIR__."/../include/config.php");
      parse_str($_POST['formData'], $_POST);
   ?>

Error:Failed load response data

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Stata 面板数据模型选择
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用