• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Need help with javascript for a auto embed script I'm working on.

lostkid

Active member
Mar 18, 2021
184
101
43
24
I'm writing a auto embed script for the MTDB script to auto embed my StreamAPI. I've written the script in php but i had to use some javascript and jquery to embed the urls in portions and return the results while the script is runnig. I just need some additional assitance adding more functionality with the javascript and jquery. I don't know much javascript and would appreciate the help.


ScreenShot_20210501224422.png
 
hi @lostkid

You can check below plugins and codes ;



and training document for jquery

 
hi @lostkid

You can check below plugins and codes ;



and training document for jquery


I appreciate you trying to help but none of these is of any use. I read the code for the WP plugin and it's just one php file that templates the iframe for the embed. While my script have a lot more to it.

ScreenShot_20210503120536.png

use jquery ajax, or fetch or axios to do it

At the moment I'm using this jquery ajax code i got from stackoverflow

ScreenShot_20210503121019.png

I just need the stop function to work as well as getting the values in a form to set the stop and start variables.
 
I appreciate you trying to help but none of these is of any use. I read the code for the WP plugin and it's just one php file that templates the iframe for the embed. While my script have a lot more to it.

ScreenShot_20210503120536.png



At the moment I'm using this jquery ajax code i got from stackoverflow

ScreenShot_20210503121019.png

I just need the stop function to work as well as getting the values in a form to set the stop and start variables.
so you want when you click button stop the ajax stop loading ?
or you want send value 10 to embed function when you click button stop ?
 
screenshot_20210503121019-png.76350


you don't need setTimeout inside runembed because the function will only run when you click button start,
and you are using settimeout without cleartimeout, it will make the ajax keep sending to embed.php for every 2 second
 
so you want when you click button stop the ajax stop loading ?
or you want send value 10 to embed function when you click button stop ?
I want the settimeout to stop when i click the stop button. and i need it to grab some input from a form
 
I want the settimeout to stop when i click the stop button. and i need it to grab some input from a form
you don't need setTimeout inside runembed because the function will only run when you click button start,
and you are using settimeout without cleartimeout, it will make the ajax keep sending to embed.php for every 2 second,
but if you just want to stop the settimeout whenever you click stop button,use this code
JavaScript:
let delay;
function runEmbed(){
embed()
delay = setTimeout(runEmbed, 2000);


}
$( "#stop" ).click(function() {
clearTimeout(delay);
});
 
Last edited:
  • Like
Reactions: lostkid
you don't need setTimeout inside runembed because the function will only run when you click button start,
and you are using settimeout without cleartimeout, it will make the ajax keep sending to embed.php for every 2 second
I want it to run every 2 seconds it make inserts the embed and returns the results in portions.
I tried using the clearTimeout function in different ways but it didnt work. Maybe setInterval might work better.

This is the embed.php file.

ScreenShot_20210503130059.png
 
I want it to run every 2 seconds it make inserts the embed and returns the results in portions.
I tried using the clearTimeout function in different ways but it didnt work. Maybe setInterval might work better.

This is the embed.php file.

ScreenShot_20210503130059.png
have you tried using the code below?
JavaScript:
let delay; // this is important to make cleartimeout work
function runEmbed(){
embed()
delay = setTimeout(runEmbed, 2000);
}
$( "#stop" ).click(function() {
clearTimeout(delay);
});

or using set interval
JavaScript:
let delay;// this is important to make clearinterval work
function runEmbed(){
embed();
delay = setInterval(embed, 2000);

}

$( "#start" ).click(function() {
  runEmbed()
});
$( "#stop" ).click(function() {
clearInterval(delay);
});
 
Last edited:
  • Love
Reactions: lostkid
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock