Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2009, 07:19 PM   PM User | #1
Toarluath
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Toarluath is an unknown quantity at this point
Question Help! Sending Request, yet no readystatechange..

So I have a problem that I can't seem to fix, no matter what I do.
The code below SHOULD create a 'slideObj' object and then use it to get some information from a php file called queryslides.php.

However, the code seems to only get to sending the request; it never RECIEVES any data back.
The function outlined in "this.request.onreadystatechange = this.infoReturn;" which is infoReturn() never gets called up. Everything before it works great, but it stops after the onreadystatechange part.

I have my code below, with comments inserted for ease of reading.
Code:
function slideObj() {
this.request = null;         //get a request object
   try {
     this.request = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       this.request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         this.request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         this.request = null;
       }
     }
   }
 
    if (this.request === null) {
     alert("Error creating request object!");  
}
 
 
 
   function sendGetServer() {
       this.request.open("GET", "queryslides.php", true); 
 
//queryslides.php is a php file with only one active line
//<?php
//echo "1|r|d~3|s|f";
//?>
 
     this.request.onreadystatechange = this.infoReturn;
     this.request.send(null);
     alert('Message Requested');  
    }
 
 
//HERE IS THE PROBLEM *****
//Every 'alert' is activated, except for those in the two functions below 
 
   function infoReturn() {
     if (this.request.readyState == 4) {
       /* Get the response from the server */
       var info = this.request.responseText;
    alert('Info recieved');
       /* Format Data */
       this.goOn(info);
      }
 
   }
 
 
//The next function works by itself, so this isn't really a problem
//
// Except for the alert line, you can just pretend the goOn() doesn't do anything.
 
        function goOn(inf) {
 
            alert('working?');
 
        }
 
this.goOn = goOn;
this.infoReturn = infoReturn;
this.sendGetServer = sendGetServer;
}
 
var hey = new slideObj();
hey.sendGetServer();
alert('end');
What can I do?
I have a link to the page here: http://hiroshifukada.no-ip.biz/sense/TEST.html~ (Note: The linked file is not EXACTLY the same as the example I gave. I'll update the file to what I show here as soon as I can.)

Last edited by Apostropartheid; 05-02-2009 at 08:59 PM..
Toarluath is offline   Reply With Quote
Old 05-01-2009, 10:04 PM   PM User | #2
Toarluath
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Toarluath is an unknown quantity at this point
Thumbs down Oops!

Sorry about this, I accidentally set the prefix to 'Resolved' even though I didn't mean too.
Can we delete this 'accidentally resolved' thread?
Toarluath is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, onreadystatechange, problem, request

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:25 PM.


Advertisement
Log in to turn off these ads.