|
|
|
|
![]() ![]() |
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 |
|
|
|
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 ![]() |
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 26th July 2008 - 04:34 PM |