Created
April 6, 2015 15:24
-
-
Save fregmented/636af899b308a1940ed3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upload(url, formdata, status){ | |
console.log("upload"); | |
console.log(url); | |
console.log(formdata); | |
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); | |
} | |
//Set progress | |
status.setProgress(percent); | |
}, false); | |
} | |
return xhrobj; | |
}, | |
url: url, | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment