-
Oct 29th, 2021, 12:19 AM
#1
Thread Starter
Member
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.
-
Oct 29th, 2021, 12:44 AM
#2
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.
-
Oct 29th, 2021, 12:46 AM
#3
Thread Starter
Member
Re: call another javascript function inside javascript function
-
Oct 29th, 2021, 01:00 AM
#4
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|