ajax传递表单值

  var CreateAritecle = function () {
        $('#addAtrcileBtn').click(function () {

            var id = '#addAtrform';
            var fd = new FormData();
            var artText = $('#sendmsg').summernote('code');

            fd.append('art_title', $('#art_title').val());   //标题
            fd.append('art_category', $('#art_category').val()); //分类
            fd.append('summary', $('#summary').val()); //说明
            fd.append('tag_id', $('#tag_id').val()); //系统帖标签
            fd.append('pay_type', $('#pay_type').val()); //系统帖标签
            fd.append('main_img',$('div.thumbnail img').attr('src')); //
            fd.append('content', artText);
           // fd.append('art_status', 1);
            fd.append('art_tag', $('#art_tag').val());
            fd.append('link', $('#link').val());
            fd.append('zip_content',  $('#browsefile')[0].files[0]);
            fd.append('pay_type', $('#pay_type').val());
            fd.append('price', $('#price').val());

            $.ajax({
                type: "POST",
                url: "../a/add-article.html",
                data: fd,
                async: false,
                processData: false,
                contentType: false,
                beforeSend: function (XMLHttpRequest) {
                    mApp.block(id, {
                        overlayColor: '#000000',
                        type: 'loader',
                        state: 'success',
                        message: '处理中...'
                    });
                    return true;
                },
                success: function (data) {
                    //成功
                    if (data.code == 1) {
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000)
                    } else {
                        return false
                    }
                    //提示窗口
                    swal({
                        title: "提示",
                        text: data.msg
                    });
                    mApp.unblock(id);
                }
            })
        })
    };

你可能感兴趣的:(php)