Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Scripting Help On Ajax Shoutbox
masugidsk8r
post Mar 23 2007, 11:22 PM
Post #1


Premium Member
********

Group: Members
Posts: 168
Joined: 21-February 07
Member No.: 38,999



HI, I'm currently working on an AJAX web app. It's a shoutbox. I have here attached the .js file fully documented so it's easy to understand.

Problem: An error message alert occurs in IE 6
Help: I need someone who can fix a code so that the error won't show up in IE.

Note: I've tested it under Firefox and Opera and it works very well.

Here's the code:

CODE
/**
* ezShout - AJAX/PHP ShoutBox
* by Albert Villaroman
*
* For help and tutorials on usage, please refer to manual
*
* Note: Due to JS lack of standard OOP conventions, treat "Shoutbox Class" comment as a class constructor,
* and all states and methods encapsulated in it are properties of the class
**/

//-----------------------------------------------------------------------------------
// Shoutbox Class
//-----------------------------------------------------------------------------------

/**
* Pre: Sates
*/

var RecieverAj; //AJAX object that makes requests to server for shouts
var SenderAj; //AJAX object that sends shout out to server and store it in database
var refresh_sb; //JS timer that will refresh list of shouts every 5 seconds
var lastShout_sb=""; //Global variable that stores last shout which is to be compared to continuosly refreshed list of shout outs - Purpose: to prevent repetitive refresh of the list


/**
* I. Obtain latest shouts from database every x seconds
*/

//request the server for latest shouts
function loadShouts_sb() {
RecieverAj = new ajaxConn();
RecieverAj.serverscript = "ezShout/includes/procedures/fetchShouts.php";
RecieverAj.setValues("rand=" + Math.random());
RecieverAj.connect("displayShouts_sb", "GET");
}
window.onload = loadShouts_sb();

//display list of shouts when response from server is recieved
function displayShouts_sb (response) {
switch (response) {
case lastShout_sb: break;
default: alert("hi"); document.getElementById("shoutcontents_sb").innerHTML = response; lastShout_sb = response; setRefreshTime_sb(); break;
}
}

//set a Timer that runs loadShouts_sb in 5 seconds
function setRefreshTime_sb() {
refresh_sb = setTimeout('refreshShouts_sb()', 5000);
}

//request again after 5 seconds
function refreshShouts_sb () {
RecieverAj.connect("displayShouts_sb", "GET");
clearTimeout(refresh_sb);
refresh_sb = setTimeout('refreshShouts_sb()',5000);
}




/**
* II. Send a shout out to the server and store it in database
*/

//onSubmit, send `name` and `message` input to server via `SenderAj`
function sendShout_sb () {
var name = document.getElementById("shouter_sb").value;
var message = document.getElementById("shout_sb").value;

SenderAj = new ajaxConn();
SenderAj.serverscript = "ezShout/includes/procedures/sendShout.php";
SenderAj.setValues("name=" + name + ",message=" + message + ",rand=" + Math.random());
SenderAj.connect("isShoutSuccessful_sb", "POST");
}

//check if shout out sent is stored in the database; successful
function isShoutSuccessful_sb (response) {
switch (response) {
case "true": alert("Your shout has been sent."); break;
case "false": alert("Unsuccessful post. Please report this."); break;
}

document.getElementById("shout_sb").value = "your message";
document.getElementById("shout_sb").style.background = "#E9E9E9";
}

//clear value of selected object
function clearValueOf_sb(object) {
object.value = "";
object.style.background = "#FFFFFF";
}

//-----------------------------------------------------------------------------------
// End of Shoutbox Class
//-----------------------------------------------------------------------------------


You can view the application here: click here
Go to the top of the page
 
+Quote Post
Saint_Michael
post Mar 24 2007, 04:53 AM
Post #2


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,314
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



Well you get that same error message in IE 7 as well "unsuccessful post, report this" Of course my knowledge of ajax is limited but I would say the problem lies somewhere in here

CODE
/**
     * II. Send a shout out to the server and store it in database
     */
    
    //onSubmit, send `name` and `message` input to server via `SenderAj`    
    function sendShout_sb () {
        var name = document.getElementById("shouter_sb").value;
        var message = document.getElementById("shout_sb").value;
    
        SenderAj = new ajaxConn();
        SenderAj.serverscript = "ezShout/includes/procedures/sendShout.php";
        SenderAj.setValues("name=" + name + ",message=" + message + ",rand=" + Math.random());
        SenderAj.connect("isShoutSuccessful_sb", "POST");
    }


in the post function and the connection to the database that is storing this shouts, take a look at your php file and see if you happen to forget to add a piece of code inthe php file that is failing to connect the db to the shoutbox.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Make A Flat Based Shoutbox, With Auto Refresh.(6)
  2. Integrity Checks Failing During Multiple Ajax Request(1)
  3. Ie 7 Issue With Ajax(2)
  4. Tutorial Needed?!(11)
  5. Shoutbox For Phpbb3(1)
  6. Tutorial: Installing D-shoutbox For Ipb V1.2(12)
  7. Truefusion Shoutbox(31)
  8. Ajax: Achieve Ajax Program In 5 Lines Of Code!(1)
  9. I Liked This Form Builder(4)
  10. Problems With Trying To Validate Ajax Called Html(1)
  11. Zk(1)
  12. Auto-installer Scripting(1)
  13. Ajax Functions On Free Host(6)
  14. Php - Ajax: E-mail Protection, Clickable Image(2)
  15. Scripting Help(4)
  1. Ajax Request Messing Up Format(1)
  2. Ajax - Internet Messenger (im) Connected To Ym, Jabber, Gtalk(2)
  3. Simple Shoutbox In Php(2)
  4. Real Time Updating With Ajax(5)
  5. Ajax Code Need Help Debugging.(9)
  6. Ajax - A New Technology(10)
  7. Faux Ajax Loading - Css Only(3)
  8. Simple Shoutbox(34)
  9. D-22 Shoutbox Not Working [resolved](3)
  10. Shoutbox For Invisionfree(6)
  11. How Can I Make An Auto-updating Shoutbox Type Script?(4)
  12. Coldfusion Scripting(0)
  13. Concerns On Ajax With Java(3)
  14. Shoutbox Not Showing In Netscape Navigator(3)
  15. Ruby On Rails, Ajax, Scriptaculous, Etc.(2)


 



- Lo-Fi Version Time is now: 26th July 2008 - 04:34 PM