How to upload content using ajax with progress bar in cakephp

Upload the content using the Ajax with progress bar :

ajax_upload

First add the progress tag in the page where you want.<progress value=’0′ max=’100′ style=’width:300px;’>
After add the progress tag add this Ajax functionfunction upload_data(){
var form = get the form data using id;
$.ajax({
url: set the url here,
type: ‘POST’,
dataType:”json”,
xhr: function() {
var myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener(‘progress’,progress, false);
}
return myXhr;
},

//beforeSend: functionname,
success: function (res) {
if(res.error){
$(“#progress”).empty();
alert(res.error);
$(“#add_module :input”).prop(“disabled”, false);
}else{
$(“#moudule_name”).val(res.module_name);
$(“#add_module :input”).prop(“disabled”, false);
$(“#add_module”).submit();
}
},

//error: errorfunction,
data: form,
cache: false,
contentType: false,
processData: false
});
}
function progress(e){
if(e.lengthComputable){

$(‘progress’).attr({value:e.loaded,max:e.total});
}
}