JqueryAjax送信を介して複数のファイルをアップロードしようとしています。
送信後、。を追加しても、ブラウザはフォームで指定されたURLに移動することを除いて、すべて正常に機能しReturn False
ます。
$("#upload").serialize(),
の代わりに使用すると、FormData
リダイレクトされません。これが私のCoffeescriptコードです:
# Initialization code
$("#upload").submit ->
ajaxUpload()
return false
# Handler
ajaxUpload = ->
fd = new FormData()
files = $("#uploadFiles")[0].files
$.each files, (i, file) ->
fd.append("file" + i, file)
$.ajax
type: $("#upload").attr("method"),
url: $("#upload").attr("action"),
data: fd,
# data: $("#upload").serialize(),
success: (data, text, xhr) ->
debug "Success: " + JSON.stringify(data)
loadEventAgain()
error: (xhr, status) ->
debug "Error: " + JSON.stringify(xhr)
alert "done"
return false