Reputation: 3
Here is the situation: I have a link of a page that gives only 1 or 0; http://www.mybilet.com/connectors/functionAjax.php?islem=getBosDoluKoltuk&serverId=228&showtimeId=46666
Page is not mine. So I want to build an alarm system in another page according to this value. i.e. if the value is 1, the page plays a music. How can I get this value and write the if statement in Javascript.
Upvotes: 0
Views: 978
Reputation: 98796
Request the page synchronously via an XMLHttpRequest
, then do the if
statement.
E.g., roughly:
var request = new XMLHttpRequest();
request.open("GET", "http://www.mybilet.com/connectors/functionAjax.php?islem=getBosDoluKoltuk&serverId=228&showtimeId=46666", false) // Passing false as the last argument makes the request synchronous
request.send(null);
if(request.responseText == '1') {
// Play music
}
Ooh yes: as the other answer demonstrates, it’s a bit less fiddly if you use jQuery. But I reckon it’s good to get your hands dirty with some Real Man’s JavaScript once in a while :)
Upvotes: 2