Hey, I wanna use this code to display now playing songs on my shoutcast server. But the thing is it doesnt work with firefox but it does with IE... usually its the other way around <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Shoutcast Now Playing Using AJAX</title> <script language="javascript" type="text/javascript"> var url = "http://advancedvi.be:8000/7.html"; function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); http.open('GET', url); http.onreadystatechange = handleResponse; http.send(null); function handleResponse() { if(http.readyState == 4){ var response = http.responseText; var update = new Array(); if(response.indexOf(',' != -1)) { update = response.split(','); if (update[1] == 1) { document.getElementById('playing').innerHTML = update[6]; } else { document.getElementById('playing').innerHTML = 'Server Offline.'; } } } } </script> </head> <body> <b>Currently Playing:</b> <div id="playing"></div> </body> </html> HTML:
Hi, Possibly because of this line: if(response.indexOf(',' != -1)) { Code (markup): Try rewrite it as: if(response.indexOf(',') != -1) { Code (markup):
Remember, if you're hosting it on another website to the "http://advancedvi.be:8000/7.html" then the browser won't allow the connection for XSS hacking issues. You can't make AJAX-based requests to third parties and manipulate the content as the request is signed to the user, not the server so it's considered hacking.