简体   繁体   中英

Check if a Radio Streaming url is working or not with Javascript

Hi I'm doing a website which contains several radios. I need to know, through javascript, if a radio stream url is working or not. I achieve this in PHP doing a file_get_contents($radio_source, false, NULL, -1, 600); , doing this I know that if the request reached the limit (600) then the request is alive, otherwise, not. My question is: Does exist a way to do this in Javascript?. So far, $.ajax doesn't seems to be an option, because doesn't have any parameter to help me to achieve this.

You can use this cool function built for javascript: https://github.com/kvz/phpjs/blob/master/functions/filesystem/file_get_contents.js . That uses XMLHttpRequest

You could have the same code that you do in php now, but refer to it with an ajax request.

I know you said no ajax, but I mean referring to the php file, not the radio stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM