Hi there,
I need to hit few list of sites from my application and find the response time of those site and sort them (which ever is opening first will sit at the top). I have done the same using java (server side). Now my requirement is do in the client side (AJAX possibly). I’m having two challenges. Below is what I have done so far,
Challenge 1: I’m using “var url="http://localhost:8080/";” because I’m unable to use urls of google, yahoo or bytes here. Getting “Access Denied” error. Cross domain scripting is not possible here.
So, any clues on cross domain scripting/proxy??
Challenge 2: “if(xmlHttp.rea dyState==4)”. Inside this function I get the responseText. Now all I want is, a way to find whether the url is responding or not (getting opened or not).
Reason: only if I know whether the site is accessible, (and if yes, how long?) I can proceed (since I’m calculating the response time here… like I have mentioned on the top).
I believe I have briefed my issue as much as possible. If it’s still not complete, kindly tell me on which part should I further explain. Thank you.
fREDDIE
I need to hit few list of sites from my application and find the response time of those site and sort them (which ever is opening first will sit at the top). I have done the same using java (server side). Now my requirement is do in the client side (AJAX possibly). I’m having two challenges. Below is what I have done so far,
Code:
<script>
function call()
{
var d = new Date();
var xmlHttp;
try
{ // Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{ // Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
alert(xmlHttp.responseText);
/* if(xmlHttp.responseText != undefined);
var res_min = d.getMinutes();
var res_sec = d.getSeconds();
var res_time = res_min*60+res_sec;
alert(res_time);
response_time=res_time-req_time*/
}
}
var req_min = d.getMinutes();
var req_sec = d.getSeconds();
var req_time = req_min*60+req_sec;
alert(req_time);
var url="http://localhost:8080/";
// url=url+"?q="+q;
xmlHttp.open("GET",url,true);
xmlHttp.send();
}
</script>
So, any clues on cross domain scripting/proxy??
Challenge 2: “if(xmlHttp.rea dyState==4)”. Inside this function I get the responseText. Now all I want is, a way to find whether the url is responding or not (getting opened or not).
Reason: only if I know whether the site is accessible, (and if yes, how long?) I can proceed (since I’m calculating the response time here… like I have mentioned on the top).
I believe I have briefed my issue as much as possible. If it’s still not complete, kindly tell me on which part should I further explain. Thank you.
fREDDIE
Comment