【问题标题】:Image is not passing with serialize formdata on ajax request图像未通过 ajax 请求序列化 formdata 传递
【发布时间】:2019-10-24 06:21:26
【问题描述】:
    jQuery(document).ready(function(){
    jQuery('#fupForm').on('submit', function(e){
        e.preventDefault();
        var formdata = jQuery("#fupForm").serialize()
        jQuery.ajax({
              url: ajaxurl,
              data : {
                     formdata, 
                     action:'my_ajax_callback_function'
                    },
              type: "POST",
              beforeSend: function(){
                jQuery('#fupForm').css("opacity",".5");
            },
              success: function(response){
                  alert(response);
                  jQuery('#fupForm').css("opacity","");
              } 
        });
    });
});
jQuery(document).ready(function($) {
    jQuery("#datepicker").datepicker();
});
  function img_pathUrl(input){
    jQuery('#img_url')[0].src = (window.URL ? URL : webkitURL).createObjectURL(input.files[0]);
}

我只是在我的 function.php 中使用 print_r() 打印完整的表单数据,但它没有显示图像名称

【问题讨论】:

    标签: php wordpress customization custom-post-type


    【解决方案1】:

    使用 FormData() 代替 serialize() 方法。

    var formData = new FormData(this);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 2012-07-12
      • 2021-11-01
      • 2014-10-19
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      相关资源
      最近更新 更多