Results 1 to 4 of 4

Thread: call another javascript function inside javascript function

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2021
    Posts
    38

    call another javascript function inside javascript function

    Code:
    <script>
                             function callB()
    			 {				 
    				  callA();
    			 }
    
    			 function callA()
    			 {
    				  alert("called");
    			 }	
    
    			 function callC()
    			 {
    				  //some php_curl code that takes time to execute;
    			 }		
    </script>
    While I execute the code on <body onload="callB()";> but it is somehow also executing callC that makes the executing onload take time.
    But if I delete the function callC from the script, the execution is fast.

    What can I do so that the function callC is still on the script but will not affect the execution time of callB ?
    Last edited by dday9; Oct 29th, 2021 at 09:34 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,118

    Re: call another javascript function inside javascript function

    Can you put an alert on callC just to make sure it is also being called? You can try putting the callC function in another js file and just load it before the Body end tag.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2021
    Posts
    38

    Re: call another javascript function inside javascript function

    I will try.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2021
    Posts
    38

    Re: call another javascript function inside javascript function

    I am revising my code below and it does not affecting the slow execution. I have another goal to achieve which is if callC results to zero length string, then callB will sleep for 2 seconds and call callC function again like a loop. but for some reason it is not looping that way.
    Code:
    <script>
    			var ii=0;
    			function callC() 
    				{																					
    					var hp = 'some curl codes';																																																																											
    					ii=hp.length;
    					document.open();
    					document.write(hp);
    					document.close();										
    				}		
    		</script>
    		<script>		
    			function callB()
    			 {				
    					callC();
    					sleep (2000);
    					if (ii = 0)
    					{
    						callC();
     					}
                                          				
    			 }
    
    			 function callA()
    			 {				  
    				  alert("done ");
    			 }				
    		</script>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width