May 17, 2008

Scripting Help On Ajax Shoutbox

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Java, Java Servlets, Java Script, & JSP

free web hosting

Scripting Help On Ajax Shoutbox

masugidsk8r
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

 

 

 


Reply

Saint_Michael
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.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : scripting ajax shoutbox

  1. Ajax: Achieve Ajax Program In 5 Lines Of Code! - (1)
    Well Last night, after a week of irritation and errors I finally created an easy Javascript object
    that easily and quickly allows you to develop an AJAX program in just 5 easy steps! Here's
    the link to the object I've created: http://www.demolaynyc.astahost.com/ajaxConn/ajaxConn.js
    Download it and read the Readme file that's under the same directory:
    http://www.demolaynyc.astahost.com/ajaxConn/Readme.html Basically what this object does is to
    connect to a server-side script (".php, .asp, .jsp, etc"), and what ever this script displays is
    sent back ...
  2. Ajax Request Messing Up Format - need help to figure out a better way to do this. (1)
  3. Ajax Code Need Help Debugging. - (9)
    I did a tutorial on ajax started to write my own It was all working well under safari but when i
    tried to test it out on other broswers it doesnt seem to work at all. I've spend a few hours
    already going over it and cant seem to figure it out at this stage. Heres the code that works under
    safari function createRequestObject(){ var request_o; //declare the variable to hold the object.
    var browser = navigator.appName; //find the browser name if(browser == "Microsoft Internet
    Explorer"){ /* Create the object using MSIE's method */ request_o = new ActiveXObj...
  4. Shoutbox For Invisionfree - (6)
    can anyone give me a Shoutbox for Invisionfree thanks alot cuz i need it for my forum and i want to
    put it in bottom of my banner /happy.gif" style="vertical-align:middle" emoid="^_^" border="0"
    alt="happy.gif" /> thanks a lot...
  5. Concerns On Ajax With Java - (3)
    Source article from Sun: http://java.sun.com/developer/technicalArticles/J2EE/AJAX/ Well, from
    this article, it shows that Ajax can be achieved with Java using Java Servlets or JSP's. For
    those who don't know what AJAX is, it's an object in Javascript technology that allows for
    instant communication between client-side and server-side. It's like changing a page's
    content without having to reload the whole page. Let's move on... Now when I looked at the JSP
    source code, the servlet's function was to simply validate a text and send back a r...
  6. Remote Ajax - Wtf?! (1)
    Any reason why Ajax doesn't work remotely? It looks almost as if ajax only works if its getting
    or sending info from the same server. What gives? could this have anything to do with the possible
    abuse of brute force scripts? If so, wouldn't this be a limitation in the browser only? Are
    there any browsers that allow remote Ajax? ...or am I doing something wrong? (I left that question
    at the end for a reason... I am sure that my script is flawless seeing as it works perfectly if i
    try to access something locally, but the second I try something remote, no info ...
  7. Help With Ajax - I can't figure it out... (0)
    Hello, I have recentlty ran into a problem on my website : When a user logs in, it adds him to an
    active users list in the MySQL database, but if they don't click the "logout" button, and just
    leave the site, it keeps them in the active users list forever until I manually go into the database
    and take them out. I heard from a friend that you could use AJAX to find out if the user is active,
    if he's not and he stays inactive for a certain amount of time, then it will take him out of the
    active users list. So I go to learn AJAX because all of the other languages I...
  8. Ajax Web Apps - (0)
    Well I just finished learning AJAX and want to start an AJAX web application. the thing is that I
    don't know what kind of application I want to work on so I'm asking you guys to come up
    with one that will use HTML, CSS, Javascript and PHP. Nothing too big but nothing to small as well.
    I'm starting a small ShoutBox. I want a type of application that would be used by companies. I
    have a software in mind where companies like Fast Food restaurants could install on their websites
    and have customers easily make orders while employees will see incoming orders live...
  9. Ajax And Php - question (9)
    Hi Dears i want learn Ajax , i know PHP and mysql , i want include ajax interface into my php
    projects . but i can not find tutorial about ajax in pixel2life.com or google. i need good tut about
    begin ajax and how its work and more samples to use if you have good link about ajax plz post here
    And if you about ajax software kit plz post here thanks /smile.gif" style="vertical-align:middle"
    emoid=":)" border="0" alt="smile.gif" /> ...
  10. Ajax Shoutbox For Ipb - Beta 2 Release - (4)
    Hi guys, Here's one of our preview releases of the projects going on under Antilost - an AJAX
    based ULTRA-LIGHT (only 20KB) Shoutbox, that works extremely fast and without refreshing your whole
    page. Can be easily integrated into IPB - although full integration module not ready yet. A
    demonstration can be found at: http://www.antilost.com/community/ Keep in mind that this is a
    develpomental release and is not completed yet. As we finish more and more of the coding part, the
    subsequent releases will be readily made availabel for download. So make sure you keep c...
  11. Ajax - Anybody else using it? (14)
    Hi everybody, I'm starting to use AJAX (Asynchronous Javascript And Xml), and it is quite nice
    and very cool. I was just wondering if anyone else is using it here yet?? Thanks! ...
  12. Glowing text on mouseover... - java scripting .. (4)
    One more script for today ... /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" /> The text glows on mouseover of the page which will draw the eyes of your
    visitor. Good to use on important lines of text that you want noticed. The colors can be changed
    easily to blend in with your background color, as can be the font style and size. Installation:
    STEP 1: Copy the code below and paste this into the of your html document. Comments have been
    inserted where you change the text size, type and colors at the top part of the scr...



Looking for scripting, ajax, shoutbox

Searching Video's for scripting, ajax, shoutbox
advertisement



Scripting Help On Ajax Shoutbox



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE