2
我創建了一個AJAX拖放文件上傳表單。但是當上傳完成時,它會顯示文件上傳已完成。但我希望它被重定向到另一個頁面。我怎樣才能做到這一點?AJAX拖放
這是我的代碼
function sendFileToServer(formData,status)
{
var uploadURL ="upload.php"; //Upload URL
var extraData ={}; //Extra Data.
var jqXHR=$.ajax({
xhr: function()
{
var xhrobj = $.ajaxSettings.xhr();
if (xhrobj.upload)
{
xhrobj.upload.addEventListener('progress', function(event)
{
var percent = 0;
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable)
{
percent = Math.ceil(position/total * 100);
}
status.setProgress(percent);
}, false);
}
return xhrobj;
},
url: uploadURL,
type: "POST",
contentType:false,
processData: false,
cache: false,
data: formData,
success: function(data){
status.setProgress(100);
$("#status1").append("File upload Done<br>");
}
});
status.setAbort(jqXHR);
}
設置了window.location到你要直接到 – Yoda
您可以在upload.php的做網址:回聲「」 –
不過其顯示文件上傳完成 –