如何使用此代码将一个参数传递给php文件

时间:2015-04-03 04:33:59

标签: php jquery ajax

这里是jquery代码

$(function(){
            var file_type = '';
            var btnUpload=$('#BackgroundimageUpload');
            var status=$('.status');
            new AjaxUpload(btnUpload, {
                action: "common_files/cover_image_change.php",
                //Name of the file input box
                name: 'uploadfile',
                onSubmit: function(file, ext){
                    file_type = ext;
                    status.html('uploading....');
                },
                onComplete: function(file, response){

                    //On completion clear the status
                    status.html('');
                    //Add uploaded file to list
                    if(response==="upload_error"){
                        alert("Error in upload");
                    } else{

                        var imgHtml = '<br/><br/><div><img src="uploads/'+response+'" style="width:100%; height:1004;" /></div>';

                        $("#timelineBackgroundUploading").html('');
                        $("#timelineBackgroundUploading").append(imgHtml);
                    }
                }
            });

        });

`

这是上面的代码,我想再传递一个参数(id)到php文件。我怎样才能做到这一点。

2 个答案:

答案 0 :(得分:0)

尝试使用&#34; params&#34;,

这样传递
new AjaxUpload(btnUpload, {
            action: "common_files/cover_image_change.php",
            //Name of the file input box
            name: 'uploadfile',
            onSubmit: function(file, ext){
                this.setData({id: your_id});
                file_type = ext;
                status.html('uploading....');
            },

答案 1 :(得分:0)

您也可以使用此方法

  

操作:&#34; common_files / cover_image_change.php?id =&#34; + id,

相关问题