hello everybody,
I have a problem using AJAX and I hope you can help me.
My java script fail to connect to my Web Container and thus fails to
download the content generated by my servlet .
I use the following code and a full URL as follows
var xmlHttp
function refreshManually(){
}
function refreshTables()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="http://10.50.52.55:8084/EASYBourse/
refreshTablesServlet";
xmlHttp.onreadystatechange=stateChanged();
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4){
alert("sucess");
document.getElementById("quotes").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try{// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}catch (e){// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
thank you very much for your help...
Best regards,
replace the function stateChanged, add " && xmlHttp.status == 200" in if
condition
function stateChanged()
{
if (xmlHttp.readyState==4 && xmlHttp.status == 200) {
alert("sucess");
document.getElementById("quotes").innerHTML=xmlHttp.responseText;
}//if
}//stateChanged
On 4/17/07, chet@gmail.com <chet@gmail.com> wrote:
> hello everybody,
> I have a problem using AJAX and I hope you can help me.
> My java script fail to connect to my Web Container and thus fails to
> download the content generated by my servlet .
> I use the following code and a full URL as follows
> var xmlHttp
> function refreshManually(){
> }
> function refreshTables()
> {
> xmlHttp=GetXmlHttpObject();
> if (xmlHttp==null)
> {
> alert ("Your browser does not support AJAX!");
> return;
> }
> var url="http://10.50.52.55:8084/EASYBourse/
> refreshTablesServlet";
> xmlHttp.onreadystatechange=stateChanged();
> xmlHttp.open("GET",url,true);
> xmlHttp.send(null);
> }
> function stateChanged()
> {
> if (xmlHttp.readyState==4){
> alert("sucess");
> document.getElementById("quotes").innerHTML=xmlHttp.responseText;
> }
> }
> function GetXmlHttpObject()
> {
> var xmlHttp=null;
> try{// Firefox, Opera 8.0+, Safari
> xmlHttp=new XMLHttpRequest();
> }catch (e){// Internet Explorer
> try{
> xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
> }catch (e){
> xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
> }
> }
> return xmlHttp;
> }
> thank you very much for your help...
> Best regards,
--
-----------------------------------------------
Valdemar Jnior
Desenvolvedor Java
WebSite:
http://www.valdemarjr.net Mobile: (+55) (83) 8847 6150
-----------------------------------------------