| | |
AJAX in IE malfunction
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hi,
I am currently writing a chatprogram, and it works fine in FF but it doesnt refresh as it should every 1500ms (set with setInterval("retrieve_messages()",1500) in body tag) in IE. The object ajax is made in previous code.
I wrote the following code:
IE says that there is something not implemented on line 9 (ajax.onreadystatechange=.....), could somebody help me out?
~Graphix
EDIT: I am currently going to bed, i will be back tomorrow.
I am currently writing a chatprogram, and it works fine in FF but it doesnt refresh as it should every 1500ms (set with setInterval("retrieve_messages()",1500) in body tag) in IE. The object ajax is made in previous code.
I wrote the following code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function retrieve_messages() { // Checks wether the object is available: if (ajax) { ajax.open('get', 'messageretrieve.php'); // Sends request ajax.send(null); // Function that handles response ajax.onreadystatechange = setTimeout("show_messages()", 500); } else { // AJAX is not useable document.getElementById('warning').innerHTML = 'It is not possible to connect, please update your browser.'; } } // End of retrieve_messages() // Function that shows the returned text into the messagebox function show_messages() { // If everything is OK: if ( (ajax.readyState == 4) && (ajax.status == 200) ) { // Returns the value to the document document.getElementById('messagebox').innerHTML = ajax.responseText; } } // End of function show_messages()
IE says that there is something not implemented on line 9 (ajax.onreadystatechange=.....), could somebody help me out?
~Graphix
EDIT: I am currently going to bed, i will be back tomorrow.
Last edited by Graphix; Sep 15th, 2009 at 3:59 pm.
Try,
It is also good practise to establish the response handler before sending the request, so put lines 9/10 above 6/7.
Airshow
javascript Syntax (Toggle Plain Text)
ajax.onreadystatechange = function(){setTimeout("show_messages()", 500);}
Airshow
Last edited by Airshow; Sep 16th, 2009 at 7:55 am.
50% of the solution lies in accurately describing the problem!
Ok thank you, it worked
. But i also have another question, i have a small problem with my chat-program: if the users presses enter it will reload and it will log out due to the onunload="leave_chat()" part. But if i delete the form i cant referer to the text input and as so cant retrieve the value typed in the textbox.
Eg:
. But i also have another question, i have a small problem with my chat-program: if the users presses enter it will reload and it will log out due to the onunload="leave_chat()" part. But if i delete the form i cant referer to the text input and as so cant retrieve the value typed in the textbox.Eg:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<body onload="setInterval('retrieve_users()', 1500); setInterval('retrieve_messages()', 1500)" onunload="leave_chat()"> .... .... not relevant HTML ..... <form method="post" name="sendform" action="defaultchat.php"> <input type='text' name='textbox' id='textbox' maxlength='255' size='75' /><input type='button' value='Send Message' onclick='send_message()' /> </form>
Last edited by Graphix; Sep 17th, 2009 at 11:44 am.
Graphix,
You need to suppress the form's natural tendency to want to be submitted when a field has focus and user hits enter. That's fairly simple to cure because the form (as far as I can see) never needs to be submitted. Two options immediately come to mind:
1. Reduce the <form ...> tag to <form>, and call send_message with
2. Leave the form tag in place but change it to :
Goood luck
Airshow
You need to suppress the form's natural tendency to want to be submitted when a field has focus and user hits enter. That's fairly simple to cure because the form (as far as I can see) never needs to be submitted. Two options immediately come to mind:
1. Reduce the <form ...> tag to <form>, and call send_message with
onclick='send_message(this.form.textbox.value)' to make the user-entered text available as an argument to the function.2. Leave the form tag in place but change it to :
javascript Syntax (Toggle Plain Text)
<form name="sendform" onsubmit="return false;">
onsubmit="return false;" ensures that the form will not be submitted, whilst your button's onclick="send_message()" will still work.Goood luck
Airshow
Last edited by Airshow; Sep 17th, 2009 at 1:48 pm.
50% of the solution lies in accurately describing the problem!
![]() |
Similar Threads
- Ajax help please... (JavaScript / DHTML / AJAX)
- News Story: It’s Like AJAX for Ruby and Python (Ruby)
- Roblox seeks Web Developer – .NET / Ajax or DHTML (Web Development Job Offers)
- JavaScript / AJAX Guru (Software Development Job Offers)
- AJAX & PHP Developer ( Full Time ) (Web Development Job Offers)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
- News Story: Atlas is dead: long live ASP.NET 2.0 AJAX Extensions... (ASP.NET)
- HARDWARE MALFUNCTION (Troubleshooting Dead Machines)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Prototype Ajax error?
- Next Thread: ajax progress bar while php exec command
| Thread Tools | Search this Thread |
Tag cloud for ajax, error, onreadystatechange
-xlint 429 adobe ajax ajaxexample alphafive amf apax application arax asp beta blue browser bsod business c# c++ cart char* class code codes compatible compile compiler computer css developer development dojofoundation eclipse email embedded error ext file flex form frameworks google gui gxt ie8 input java javascript javascripts jni jsf jsp linker listbox microsoft mistake mouse msdn mysql office onreadystatechange output parse php port post problem programming python reference reformat rms ruby rubyconf runtime screen scriptlets search security server session software sources space sql synchronous syntax templates tracking ui validation variables vb vb2008 virus vista visual webbrowser windows xml zend






