dcsimg
AJAX+STRUTS Problem?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, September 11, 2006 09:53 AM

function checkMessages(){ if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = processStateChange; try { req.open("GET", "checkMessage", true); } catch (e) { alert(e); } req.send(null); } else { if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { try { req.onreadystatechange = processStateChange; req.open("GET", "../cm.do", true); req.send(); } catch(e){alert("Error="+e);} } } } setTimeout("checkMessages()", 5000);} Above is the javascript function which gets called on body load first up and automatically then onwa   More>>

function checkMessages(){ if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = processStateChange; try { req.open("GET", "checkMessage", true); } catch (e) { alert(e); } req.send(null); } else { if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { try { req.onreadystatechange = processStateChange; req.open("GET", "../cm.do", true); req.send(); } catch(e){alert("Error="+e);} } } } setTimeout("checkMessages()", 5000);}





Above is the javascript function which gets called on body load first up and automatically then onwards with set timer



The problem i am facing is when first up the body gets loaded the action for ../cm.do gets called but not after



What could be the reason for this?



Is there any other way?


Manoj Amrutkar

   <<Less

Re: AJAX+STRUTS Problem?

Posted By:   murali_sappa  
Posted On:   Friday, September 15, 2006 07:40 PM

Hi Manoj,

Without seeing your processStateChange method it is difficult to say what the problem is. Also, I am wondering, why would you set the onreadystatechange for IE different from that of non-IE browsers!!!.

To test your script, I added a few lines of HTML and a dummy processStateChange method. If you run this on IE, you should see an alert message every 5 seconds - So, you may have to check your processStateChange method and the difference in the logic for IE 'vs' non-IE -
What follows is the html file that you can try









test.html


Testing AJAX


checkMessages ...




About | Sitemap | Contact