By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

[Ajax] Please wait and progress bar

P: 4
Hi all, I need ur appreciated help.

This code no errors but not working because I don't see the `progressBarLong.gif` (Please Wait), but I see instantly the alert `The server script has now completed` and redirect in the server-side page where right output of the form.

Can u help me?

Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <HEAD>
  4. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
  5.  
  6. <script language="javascript" type="text/javascript"> 
  7.  
  8.         var url = 'default-1.asp?rand=';
  9.  
  10.         function getHTTPObject()
  11.         {
  12.         try {
  13.         req = new XMLHttpRequest();
  14.           } catch (err1)
  15.           {
  16.           try {
  17.           req = new ActiveXObject("Msxml12.XMLHTTP");
  18.           } catch (err2)
  19.           {
  20.           try {
  21.             req = new ActiveXObject("Microsoft.XMLHTTP");
  22.             } catch (err3)
  23.             {
  24.     req = false;
  25.             }
  26.           }
  27.     }
  28.         return req;
  29.     }
  30.  
  31.         var http = getHTTPObject();      
  32.  
  33.         function handleHttpResponse() {
  34.         if (http.readyState == 4 && http.status==200) {
  35.               document.getElementById('wait').style.visibility = "hidden";
  36.               alert('The server script has now completed');
  37.            } else {
  38.               document.getElementById('wait').style.visibility = "visible";
  39.             }
  40.         }
  41.  
  42.         function longcall() {
  43.         myRand=parseInt(Math.random()*999999);
  44.         http.open("GET", url + myRand, true);
  45.         http.onreadystatechange = handleHttpResponse;
  46.         http.send(null);
  47.         }
  48.  
  49.  
  50.  
  51. function PopUp() {
  52.  
  53.    var w = 400;
  54.    var h = 400;
  55.    var l = Math.floor((screen.width-w)/2);
  56.    var t = Math.floor((screen.height-h)/2);
  57.  
  58.    finestra=window.open('mystartpage.asp','','width=' + w + ',height='+ h + ',top=' + t + ',left=' + l+',scrollbars=no,menubar=no,toolbar=no,status=no');
  59.  
  60. }
  61.  
  62. function atLeastOneChecked(form) {
  63.  
  64.    var inputs = form.getElementsByTagName('input');
  65.    var i = inputs.length;
  66.    while (i--) {   
  67.  
  68.       if(inputs[i].checked && !inputs[i].disabled)
  69.  
  70.          if(confirm("Confirm????.")) {
  71.             PopUp();             
  72.             return false;
  73.             } else {
  74.             return true; 
  75.             }          
  76.    }
  77.  
  78.    alert("ko!")
  79.    return false;
  80.  
  81. }
  82.  
  83.  
  84. </script>
  85.  
  86. </HEAD>
  87. <title>Multiple checkbox select sample</title>
  88. <BODY>
  89.  
  90.  
  91.  
  92. <form name=frmTest action="default-2.asp" method=POST onsubmit="return (atLeastOneChecked(this) && longcall());">
  93.  
  94.  
  95. <input type=CHECKBOX name=chkParent1 value="3742">karla_c26<br>
  96.  
  97. <input type=CHECKBOX name=chkParent2 value="4430">AleAlvarez<br>
  98.  
  99. <input type=CHECKBOX name=chkParent3 value="3303">Alejandra<br>
  100.  
  101. <input type=CHECKBOX name=chkParent4 value="3720">Angio<br>
  102.  
  103. <input type=CHECKBOX name=chkParent5 value="3">gino<br>
  104.  
  105. <input type=CHECKBOX name=chkParent6 value="4606">Andrea<br>
  106.  
  107. <input type=CHECKBOX name=chkParent7 value="3962">alx<br>
  108.  
  109. <input type=CHECKBOX name=chkParent8 value="4095">ANGELADAUTO<br>
  110.  
  111. <input type=CHECKBOX name=chkParent9 value="7">chinga cas<br>
  112.  
  113. <input type=CHECKBOX name=chkParent10 value="8">assim<br>
  114.  
  115.  
  116. <input type=HIDDEN name=txtCount value="10">
  117. <input type=HIDDEN name=comments value=0>
  118.  
  119. <p><input type=SUBMIT value="Select"></p>
  120. </form>
  121.  
  122. <div id="wait" style="background-color:white;position:absolute;top:240px;left:360px;width:70px;height:50px;visibility:hidden;border: 1px solid black;padding:20px;">
  123. <img src="progressBarLong.gif" style="position:relative;top:0px;left:25px">
  124. <br /><br />Please wait...
  125.  
  126. </div>
  127.  
  128. </BODY>
  129. </HTML>
  130.  
Apr 7 '11 #1
Share this Question
Share on Google+
5 Replies


JKing
Expert 100+
P: 1,206
Have you checked to ensure the path to your image is correct?
Apr 8 '11 #2

P: 4
Thanks Sir, I'm sure: the image path is correct.

Try this:
http://www.avia-it.com/bytes.com/default-1.asp
Apr 8 '11 #3

100+
P: 270
have you tried re-writing all things using jquery
Apr 9 '11 #4

P: 4
Thanks Sir.

No... I don't try jquery... Do u have some link to give me?
Apr 9 '11 #5

P: 4
Thanks, I solved with Jquery:

index.asp
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>My page1</title>
  6.  
  7. <script type="text/javascript" src="jquery-1.5.2.min.js"></script>
  8.  
  9. <script> 
  10.  
  11. function PopUp() {
  12.  
  13.    var w = 400;
  14.    var h = 400;
  15.    var l = Math.floor((screen.width-w)/2);
  16.    var t = Math.floor((screen.height-h)/2);
  17.  
  18.    finestra=window.open('pageAdd.asp','','width=' + w + ',height='+ h + ',top=' + t + ',left=' + l+',scrollbars=no,menubar=no,toolbar=no,status=no');
  19.  
  20. }
  21.  
  22. function atLeastOneChecked(form) {
  23.  
  24.    var inputs = form.getElementsByTagName('input');
  25.    var i = inputs.length;
  26.    while (i--) {   
  27.  
  28.       if(inputs[i].checked && !inputs[i].disabled)
  29.  
  30.          if(confirm("Confirm?.")) {
  31.             PopUp();             
  32.             return false;            
  33.             } else {
  34.             return true;
  35.             }          
  36.    }
  37.  
  38.    alert("ko!")
  39.    return false;
  40.  
  41. }
  42.  
  43. function loadingAjax(div_id)
  44. {
  45.     $("#"+div_id).html('<img src="ajax-loader.gif"> saving...');
  46.     $.ajax({
  47.         type: "POST",
  48.         url: "script.asp",
  49.         data: "name=John&id=28",        
  50.         success: function(msg){
  51.             $("#"+div_id).html(msg);
  52.         }
  53.     });
  54. }
  55. </script>
  56.  
  57. <title>Multiple checkbox select sample</title>
  58. </head>
  59.  
  60. <BODY>
  61.  
  62.  
  63.  
  64. <form name=frmTest action="script.asp" method=POST onsubmit="return (atLeastOneChecked(this) && loadingAjax('myDiv'));">
  65.  
  66.  
  67. <input type=CHECKBOX name=chkParent1 value="3742">karla_c26<br>
  68.  
  69. <input type=CHECKBOX name=chkParent2 value="4430">AleAlvarez<br>
  70.  
  71. <input type=CHECKBOX name=chkParent3 value="3303">Alejandra<br>
  72.  
  73. <input type=CHECKBOX name=chkParent4 value="3720">Angio<br>
  74.  
  75. <input type=CHECKBOX name=chkParent5 value="3">gino<br>
  76.  
  77. <input type=CHECKBOX name=chkParent6 value="4606">Andrea<br>
  78.  
  79. <input type=CHECKBOX name=chkParent7 value="3962">alx<br>
  80.  
  81. <input type=CHECKBOX name=chkParent8 value="4095">ANGELADAUTO<br>
  82.  
  83. <input type=CHECKBOX name=chkParent9 value="7">chinga cas<br>
  84.  
  85. <input type=CHECKBOX name=chkParent10 value="8">assim<br>
  86.  
  87.  
  88. <input type=HIDDEN name=txtCount value="10">
  89. <input type=HIDDEN name=comment value=0>
  90.  
  91. <p><input type=SUBMIT value="Select"></p>
  92.  
  93. </form>
  94.  
  95.  
  96. <div id="myDiv"></div>
  97.  
  98. </body>
  99.  
  100. </html>
script.asp
Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2.  
  3. <%
  4.  
  5.   Function Sleep(sec)
  6.      Dim Start:Start = Timer:While (Timer-Start<sec):Wend
  7.   End function   
  8.  
  9.   Sleep 5
  10.  
  11. %> 
  12.  
  13. <HTML>
  14. <HEAD>
  15. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
  16. <title>Checkbox selection</title>
  17. </HEAD>
  18. <BODY>
  19.  
  20. <%
  21. iCount = Request("txtCount")
  22.  
  23. response.write Request("commento") & "<br><br>"
  24.  
  25. if Request("comment") > "0" then
  26.    strComment = Split(Request("comment"), "-")
  27.    response.write strComment(0) & "<br>" &_
  28.                   strComment(1) & "<br>" 
  29. end if   
  30.  
  31. %>
  32. <p>
  33. There were <%=iCount%> checkboxes
  34. </p>
  35. <p>
  36. <%
  37. for i = 1 to iCount
  38.     sID = Request("chkParent" & i)
  39.     if sID = "" then
  40.         Response.Write "Item " & i & " was NOT checked<br>"
  41.     else
  42.         Response.Write "Item " & i & " was checked, it's ID is " & sID & "<br>"
  43.     end if
  44. next
  45. %>
  46. </p>
  47. </BODY>
  48. </HTML>
pageAdd.asp
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>Nuova pagina 1</title>
  6.  
  7. <script language="javascript" type="text/javascript">
  8. <!--
  9.  
  10. function insertf1(f1) {
  11.  
  12.       var re = /[^a-zA-Z0-9\''\,\.\;\:\ ]/g,             
  13.       result = re.exec(Qform.TextareaS1.value);
  14.  
  15. for ( var n = 0 ; n < Qform.elements.length ; n++ ) {
  16.       var field = Qform.elements[n];
  17.  
  18.       if (field.value.length <= 0) {
  19.           window.alert('KO');
  20.           field.focus();
  21.           field.select();   
  22.           return;            
  23.         }
  24.     }
  25.  
  26.       if (!Qform.TextareaS1.value.match("^[a-zA-Z0-9\.;,:' ]{1,100}$")) {
  27.           window.alert(' + ( result.index + 1 ) + ' "' + result + '".');
  28.           Qform.TextareaS1.focus();
  29.           Qform.TextareaS1.select();
  30.           return;
  31.     }
  32.  
  33.       else {   
  34.  
  35.           window.opener.document.frmTest.comment.value=f1;
  36.           window.alert("OK."); 
  37.           window.opener.document.frmTest.submit();
  38.           setTimeout("self.close()",300);
  39.           window.opener.loadingAjax('myDiv');
  40.  
  41.     }  
  42. }
  43.  
  44. //-->
  45. </script>
  46.  
  47. </head>
  48.  
  49. <body>
  50.  
  51. <form name="Qform">
  52.     <p>Data scadenza<input type="text" name="DataT1" size="20"></p>
  53.     <p>Commento<textarea rows="10" name="TextareaS1" cols="40"></textarea></p>
  54.     <p><a href="javascript:insertf1(document.Qform.DataT1.value+'-'+document.Qform.TextareaS1.value);">
  55.     <img border="0" src="get_ff.png" width="84" height="16"></a></p>
  56. </form>
  57.  
  58. </body>
  59. </html>
Apr 11 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.