Menu
Hai All,
I need a small help regarding javascript.Actually I implemented code in Ajax with javascript and It is working fine.But I am getting output very late because of following statement.It takes nearly 3 mints to display result.But I need output within 30 secs .Please help me to resolve these problems
Problem:
script on this page mab be busy,or it may have stopped responding.You can stop the script now,or you can continue to see if the script will complete.
govind
<i>
</i>function rate()
{
var s=new String(window._content.document.URL); <br/>
var intstr_site=s.indexOf('.');
var str_site=s.substring(intstr_site+1,intstr_site+8);
var intstrvalue=str_site.indexOf('.');
str_site=str_site.substring(intstrvalue,0);
if(str_site=='yahoo')
{
var str = s.replace(/&/g,"@" ); <br/>
var url='http://....../parse.php?parse=yahoo&name='+str;
makeRequest(s);//FIRST REQUEST FOR URL
while(source==null)
{
alert("Press Enter To Continue To Display Ratings");
};
var leng=source.length;s
var intyahoo=0,intlastyahoo=0;
var str6=source;
while(source.length>0 && intyahoo>-1)
{
//PARSING CODE
<i> </i> strlink=strlink.toLowerCase();
<i> </i> strlink=strlink.replace(''',"'");
<i> </i> var intfirst=0,intlast=0;
<i> </i> makeRequest1(url);//SECOND REQUEST FOR URL
<i> </i> while(source1==null)
<i> </i> {
<i> </i> alert("Press Enter To Continue To Display Ratings");
<i> </i> };
<i> </i> obj=source1;
<i> </i> while(source1.length>0 && intfirst>-1)
<i> </i> {
<i> </i> //PARSING CODE var strval;
<i> </i> var urlpath='http://......function.php?url='+strsubstr;
<i> </i> ajaxFunction(urlpath);//THIRD REQUEST FOR URL
<i> </i> HERE IS THE 3 rd URL WE ARE
<i> </i> REQUESTING MANY TIMES
<i> </i> WHICH IS INSIDE WHILE
<i> </i> LOOP //
<i> </i> while (showvalue==null)
<i> </i> {
<i> </i> alert("Press Enter To Continue To Display Ratings");
<i> </i> };
<i> </i> if (strlink1 == strlink)
<i> </i> {
<i> </i> if(showvalue.indexOf('<td>')>-1&&showvalue.indexOf('</td>')>-1)
<i> </i> {
<i> </i> var intvalu1=showvalue.indexOf('<td>');
<i> </i> var intvalu2=showvalue.indexOf('</td>');
<i> </i> strval=showvalue.substring(intvalu1+4,intvalu2);
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> strval=0;
<i> </i> }
var newstr=stryahoo +" " +"<a href='http://.........index.php?show=" + strval + "'
target='_blank'><font size='2' color='#FFCC33' face='Verdana'
style="visibility:visble;border:solid #000 1px;background-color:
black;background-image:url('http:/........./images/bg.jpg') color="white"><B>Rating:" +
"" + number + "- Details here.." + "</B></font></a>";
str6 = str6.replace(stryahoo , newstr);
window._content.document.getElementById('thelayer').innerHTML=str6;
}
else
{
if (strlink1.indexOf("...") > -1)
{
var str_google2 = strlink1.indexOf("...");
var str_google1 = strlink1.substring(str_google2,0);
if (strlink.length > str_google1.length)
{
strgoogle_value = strlink.substring(str_google2,0);
if (str_google1 == strgoogle_value)
{
if(showvalue.indexOf('<td>')>-1 && showvalue.indexOf('</td>')>-1)
{
var intvalu1=showvalue.indexOf('<td>');
var intvalu2=showvalue.indexOf('</td>');
strval=showvalue.substring(intvalu1+4,intvalu2);
}
else
{
strval=0;
}
var newstr=stryahoo +" " +"<a
href='http://....../index.php?show=" + strval + "' target='_blank'><font size='2'
color='#FFCC33' face='Verdana' style="visibility:visble;border:solid #000
1px;background-color: black;background-image:url('http://..../images/bg.jpg')
color="white"><B>Rating:" + "" + number + "- Details here.." + "</B></font></a>"; <br/>
str6 = str6.replace(stryahoo, newstr);
window._content.document.getElementById('thelayer').innerHTML=str6;
}
}
}
}
}
};
source1=obj;
showvalue=null;
}
};
source1=null;
source=null;
}
}//end function
function makeRequest(url)
{
if (window.XMLHttpRequest)
{
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject)
{
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
<i> </i> if (!http_request)
<i> </i> {
<i> </i> alert('Giving up :( Cannot create an XMLHTTP instance');
<i> </i> return false;
<i> </i> }
<i> </i> try
<i> </i> {
<i> </i> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
<i> </i> }
<i> </i> catch (e)
<i> </i> {
<i> </i> alert("Permission UniversalBrowserRead denied.");
<i> </i> }
<i> </i> http_request.onreadystatechange = alertContent;
<i> </i> http_request.open('GET', url,true);
<i> </i> http_request.send(null);
}
function alertContent()
{
if (http_request.readyState == 1)
{
if(window._content.document.getElementById('thelayer'))
{
window._content.document.getElementById('thelayer').innerHTML="";
window._content.document.getElementById('thelayer').innerHTML='<table border=0
style="background-color:#000000" ><tr><td ><font color="white"><b>Please wait
while ratings are collected ! </font> </b></td></tr></table>';
}
else
{
var theNewParagraph =window._content.document.createElement('div');
theNewParagraph.setAttribute('id','thelayer');
<i> </i> theNewParagraph.setAttribute('style','position:absolute;z-index:1000009;width:100%;
<i> </i> left:0;top:0;visibility:visible;border:solid #000
<i> </i> 1px;background-color: #ffffff;');
<i> </i>window._content.document.body.appendChild(theNewParagraph);
<i> </i>window._content.document.getElementById('thelayer').innerHTML='<table border=0
<i> </i> style="background-color:#000000" ><tr><td ><font color="white">
<i> </i> <b>Please wait while ratings are collected ! </b></font></td></tr></table>';
<i> </i> }
}
if (http_request.readyState == 4 )
{
source=http_request.responseText;
window._content.document.getElementById('thelayer').innerHTML=source;
}
return source;
}
function ajaxFunction(url)
{
if (window.XMLHttpRequest)
{
// Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject)
{
// IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
<i> </i> if (!http_request)
<i> </i> {
<i> </i> alert('Giving up :( Cannot create an XMLHTTP instance');
<i> </i> return false;
<i> </i> }
<i> </i> try
<i> </i> {
<i> </i> netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
<i> </i> }
<i> </i> catch (e)
<i> </i> {
<i> </i> alert("Permission UniversalBrowserRead denied.");
<i> </i> }
<i> </i> http_request.onreadystatechange = functiondb;
<i> </i> http_request.open('GET', url,true);
<i> </i> http_request.send(null);
}//end function
function functiondb()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
showvalue=http_request.responseText;
}
}
return showvalue;
}
0.1.9 — BETA 5.16