dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
-avatar_upload.js
Go to the documentation of this file.
1
2$(document).ready(function () {
3 $('#avatar_upload_button').click(function () {
4 alert('xx');
5 $('#avatar_upload').ajaxForm({
6 target: '#outputImage',
7 url: 'uploadFile.php',
8 beforeSubmit: function () {
9 $("#outputImage").hide();
10 if($("#uploadImage").val() == "") {
11 $("#outputImage").show();
12 $("#outputImage").html("<div class='error'>Choose a file to upload.</div>");
13 return false;
14 }
15 $("#progressDivId").css("display", "block");
16 var percentValue = '0%';
17
18 $('#progressBar').width(percentValue);
19 $('#percent').html(percentValue);
20 },
21 uploadProgress: function (event, position, total, percentComplete) {
22
23 var percentValue = percentComplete + '%';
24 $("#progressBar").animate({
25 width: '' + percentValue + ''
26 }, {
27 duration: 5000,
28 easing: "linear",
29 step: function (x) {
30 percentText = Math.round(x * 100 / percentComplete);
31 $("#percent").text(percentText + "%");
32 if(percentText == "100") {
33 $("#outputImage").show();
34 }
35 }
36 });
37 },
38 error: function (response, status, e) {
39 alert('Oops something went.');
40 },
41
42 complete: function (xhr) {
43 if (xhr.responseText && xhr.responseText != "error") {
44 $("#outputImage").html(xhr.responseText);
45 }
46 else{
47 $("#outputImage").show();
48 $("#outputImage").html("<div class='error'>Problem in uploading file.</div>");
49 $("#progressBar").stop();
50 }
51 }
52 });
53 });
54});