使用ajax通过启动上载按钮将POST数据加载到dump.php

时间:2013-08-01 06:15:37

标签: php ajax plupload

我想通过AUTOCLICK保存按钮使用AJAX通过PLUPUPLOAD阵列,当我按下开始上传按钮我从dump.php获取输出,如html5_Plupupload_count = 0

<form method="post" name="form1" id="form1" action="dump.php" enctype="multipart/form-data">
        <div id="html5_uploader" style="width: 600px; height: 315px;">Your browser doesn't have HTML 4 support.</div>       
    <input type="submit" value="Save" class="plupload_button" name="subsession" id="subsession"/>
    <input name="eid" type="hidden" id="eid" value="<?php echo time(); ?>" />
</form>
$(function() 
{
    $("#html5_uploader").pluploadQueue(
        {
        runtimes : 'html5',
        url : 'upload.php',        
        unique_names : true,

        filters : [
            {title : "Image files", extensions : "tiff,png,gif,jpg,jpeg,ico,bmp"}
        ]
    });
    $('.plupload_start').click(function(e)
    {   
       $('#subsession').click();
    });
    $(document).ready(function()
    {
        $('.plupload_start').click(function() 
        {
              $.ajax({
                 type: "POST",
                 url: "dump.php",
                 data: {'form1': $("#form1").serialize()},
                 success: function(msg)
                 {
                    alert("Form Submitted: " + msg);
                 }
              });
        });

    });
});

1 个答案:

答案 0 :(得分:0)

     $.post("dump.php", { 
        form1: $("#form1").serialize()
    }).done(function(msg) {  
        alert("Form Submitted: " + msg);
    });