By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

responseText is not working in Firefox

P: 1
Hi Guys,
I am using following for my code is posting data perfectly in IE & Firefox both,
but when i try to get data using responseText i return empty in firefox.
is there anyone can help me out?

Expand|Select|Wrap|Line Numbers
  1.  function createRequestObject() 
  2.      {
  3.            var xmlhttp;
  4.      try 
  5.                  { 
  6.                     xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
  7.                  }
  8.       catch(e) 
  9.                  {
  10.         try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
  11.         catch(f) { xmlhttp=null; }
  12.         }
  13.             if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
  14.                         {
  15.              xmlhttp=new XMLHttpRequest();
  16.                }
  17.            return  xmlhttp;
  18.  }
  19. function sndRating(idnum,rateval) 
  20.   {
  21.     var dvelement = document.getElementById('dv'+idnum);
  22.     var innerHTML = "";
  23.     var results = document.getElementById('results');
  24.     dvelement.innerHTML = "<img src='progressimgred.gif'>";
  25.             try
  26.               {
  27.                 http.open('GET', 'ratingprocess.asp?id='+idnum+'&rateval='+rateval);
  28.                 http.send(null);
  29. //                http.onreadystatechange = handleResponseText;
  30.                 http.send(null);     
  31.  
  32.              }
  33.             catch(e){}
  34.             finally{
  35.                 getRating(idnum);
  36.                 }
  37.  
  38.  }
  39.  
  40. function getRating(idnum) {
  41.     var dvelement = document.getElementById('dv'+idnum);
  42.     dvelement.innerHTML = "";    
  43.     var results = document.getElementById('results');
  44.     var url = 'getRating.asp?id=' + idnum;
  45.     http.open('GET', url);
  46.     http.setRequestHeader("Content-Type", "text/xml");
  47.     http.send(null);
  48.  
  49. results.innerHTML = http.responseText;
  50. //alert(http.readyState + " " + http.status);
  51. alert(http.responseText);
  52.  }
Jul 24 '08 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,343
the request is async so the response isn't ready at this time where you want to process it ... you have to assign a callbackfunction to the request-object's onreadystatechange-property and handle the responseTest there ...

kind regards
Jul 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.