I want to get subtitles from yifysubtitle,so i wrote a script to do that. When I test it in a single file, like this:
var web=new XMLHttpRequest();
web.open("GET","http://www.yifysubtitles.com/movie-imdb/tt0816692",true);
web.send(null);
web.onreadystatechange=function(){
if (web.readyState==4){
var str=web.responseText;
var subtitle=str.split(/class="reply-rating"/);
var i;
var subtitlelist="";
for(i=1;i<subtitle.length;i++){
var check=subtitle[i].split(/flag flag-cn/);
if(check.length>1){
var rating1=subtitle[i].split(/title="rating">/);
var rating2=rating1[1].split(/<\/span>/);
var rating=rating2[0];
var href1=subtitle[i].split(/href="/);
var href2=href1[1].split(/">/);
var href=href2[0];
subtitlelist=subtitlelist+rating+" http://www.yifysubtitles.com"+href+"\n";
}
}
alert(subtitlelist);
}
}
it works fine, and I get what I want. But when I try to put that code in a JavaScript file that already has another XMLHttpRequest named xhr,I get empty response text. Are there any restrictions on using two XMLHttpRequests in one file? How can I fix this?