iphone 关于ajax请求使用FormData的问题

1. 问题分析

/*
* 为了使用ajax上传图片,使用了FormData的解决方案,代码如下。
* 实际请求时:发现在iphone中在input[type=file]里面有内容的时候是可以成功请求的;
* 但是当input[type=file]里面内容为空的时候却不能成功发送请求
* (备注:Android机没遇到此情况,由此断定,是浏览器内核不同导致的)。
*/
var regData = {url:'...', isCommit:false, data:''};
$('#commitBtn').click(function(){
    if (regData.isCommit) {
        return false;
    }
    regData.isCommit = true;
    regData.data = new FormData($('#regForm')[0]);
    $.ajax({
        type: 'POST',
        url: regData.url,
        data: regData.data,
        dataType: 'json',
        contentType: false,
        processData: false,
        success: function (res) {
            console.log(res);
            regData.isCommit = false;
        },
        error: function () {
            regData.isCommit = false;
        }
    });
 });

2. 解决方案:

/**
* 因为时间比较紧急,也没寻找更好的解决方案。如果有大神有更好的解决方案的话,希望留言共享。
* 判断file是否为空,发不同的请求数据
*/

if ($('input[name=file]').prop('files').length == 0) {
    //input[type=file]为空
    regData.data = $('#regForm').serialize();
    $.ajax({
        type: 'POST',
        url: regData.url,
        data: regData.data,
        dataType: 'json',
        success: function (res) {
           console.log(res);
           regData.isCommit = false;
        },
        error: function () {
           regData.isCommit = false;
        }
    });
} else {
    //input[type=file]不为空, 执行 new FormData
}