Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ajax Programming

problem with AJAX and JSP Servlet


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:

--
-----------------------------------------------
Valdemar Jnior
Desenvolvedor Java
WebSite: http://www.valdemarjr.net
Mobile: (+55) (83) 8847 6150
-----------------------------------------------
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc