2015-05-05 37 views
2

我使用Blueimp JQuery的文件上傳,還可以選擇forceIframeTransport:真的,我能夠在文件和表單字段上傳到一個跨域端點進行處理。Blueimp jQuery的文件上傳力的iFrame傳輸服務器響應

但是,服務器的響應是什麼打擾我很長一段時間。

我也接觸過網絡有關的材料庫:

http://missioncriticallabs.com/blog/lessons-learned-from-jquery-file-upload

我也跟着鏈接的指令,但未能獲得正確的服務器響應。

這裏是我的代碼:

jQuery("#newFile").fileupload({ 
     url: "https://mydomain/cgi-bin/get_file.cgi", 
     forceIframeTransport: true, 
     type: "POST", 
     cache: false, 
     contentType: false, 
     processData: false, 
     autoUpload: false, 
     replaceFileInput: false 
     done: function(e, data) { 

      console.log("done"); 
      console.log(e); 
      console.log(data.result); 
     } 
}); 

現在,我的服務器端點是隻打印出的JSON響應:

#!C:/Perl64/bin/perl.exe 

use CGI; 
use JSON; 

print "Content-type: text/plain; charset=iso-8859-1\n\n"; 
#print header("application/json;charset=UTF-8"); 
my %rawText = (message => "Processed"); 
my $json = encode_json \%rawText; 
print $json; 

我試圖將標題打印爲「text/plain的「和‘應用/ JSON’,但我不能讓我的服務器響應‘的JS代碼完成’功能。

我的console.log(data.result)總是打印 「未定義」。

我挺新鮮的圖書館和觀念的落後,

所以我將非常感激,如果任何人都可以指導我使用這個庫。

非常感謝。

回答

相關問題