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

XMLHttpRequest status = 0 and XMLHttpRequest statusText = unknown


hi all
 i am new to this group can u help me with this code it is returning
XMLHttpRequest status = 0 and due to this the data from a file is not
being fetched iam pasting the code below

<head>
<title>Ajax at Work</title>
<script language="javascript">
        //ajax request function
        var XMLHttpRequestObject=false;
        if(window.XMLHttpRequest)
        {
                // Opera 8.0+, Firefox, Safari
                XMLHttpRequestObject=new XMLHttpRequest();
        }
        else if(window.ActiveXObject)
        {
                //Internet Explorer
                XMLHttpRequestObject=new ActiveXObject("Msxml2.XMLHTTP");
        }
        else
        {
                alert("Your Browser is not compatible");
        }

        //function to get the data from the text file
        function getData(datasource,divID)
        {
                if(XMLHttpRequest )
                {
                        var obj=document.getElementById(divID);
                        XMLHttpRequestObject.open("GET",datasource,true) ;
                        XMLHttpRequestObject.onreadystatechange=function()
                        {
                                if(XMLHttpRequestObject.readyState==4 )
                                        {
                                                alert(XMLHttpRequestObject.status);
                                                obj.innerHTML = XMLHttpRequestObject.responseText;
                                        }
                        }
                }
        }
</script>
</head>
<body>
<H1>Welcome to Gift Selection</H1>

        <img src=images\titanic.jpg
onmouseover="getData('text/titanic.txt','targetDiv')">
        <img src=images\watch.jpg
onmouseover="getData('text/watch.txt','targetDiv')">

<div id="targetDiv">
        <p>Select the Picture to get the discription</p>
</div>

///////////////////////////////////////

the data in titanic.txt n watch.txt can be anything, it just has to
retrive the data from the file n display in the same page

If it is ZERO than you are using the local file system and that means
success. You only get 200 when you are running on the http protocal

Eric

On 11/9/06, Deepanshu007 <deepanshu.shrivast@gmail.com> wrote:

Looks to me liek you're not actually askign the XMLHttp to do anything.
Try XMLHttpRequestObject.send(null); after declaring the
onreadystatechange function. Maybe you don't need that and the open
command does it just fine with GET, I dunno...

On Nov 9, 10:27 am, "Deepanshu007" <deepanshu.shrivast@gmail.com>
wrote:

thanks all but the problem is now resolved and without any webserver
the code is working in a html page only .........
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc