2015-04-03 133 views
0

这里是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); 
        } 
       } 
      }); 

     }); 

`

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

+0

格式化您的问题 – 2015-04-03 04:34:59

+0

不要尝试在评论中放置长代码块。把它放在问题中,以便可以将其格式化为可读。 – Barmar 2015-04-03 04:36:41

+0

你能给出一个链接到你正在使用的'AjaxUpload'插件的位置吗?我无法用Google找到它的文档。 – Barmar 2015-04-03 04:42:39

回答

0

试图通过这样使用 “PARAMS”,

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....'); 
      }, 
+0

nopz它不工作。它传递空白值 – 2015-04-03 05:02:36

+0

嘿ayyanar这是工作绝对好...现在告诉我我怎么能通过2更多参数...我这样做this.setData({id:your_id,名称:uname,性别:ugender }); ... btt这是行不通的 – 2015-04-03 05:38:12

+0

尝试使用单引号中的值,例如this.setData({id:your_id,name:'uname',gender:'ugender'});如果这也不工作意味着重复这样,this.setData({name:uname}); this.setData({gender:ugender}); ...让我知道它的工作与否 – 2015-04-03 05:42:03

0

您也可以使用此方法

行动: “common_files/cover_image_change.php ID =?” + ID,