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

readyState is null or not an object error

P: 10
Hi All,


I have to display the value in textbox that is selected from dropdownlistbox using ajax.i got the readyState is null or not an object error.

coding:
Expand|Select|Wrap|Line Numbers
  1.  <script language="javascript" type="text/javascript">
  2.  function GetDataViaAJAX()
  3. {
  4. var obj;
  5. try
  6. {
  7. obj = new ActiveXObject("Msxml2.XMLHTTP");
  8. }
  9. catch(e)
  10. {
  11. try
  12. {
  13. obj = new ActiveXObject("Microsoft.XMLHTTP");
  14. }
  15. catch(e1)
  16. {
  17. obj = null;
  18. }
  19. }
  20. if(obj!=null)
  21. {
  22. obj.onreadystatechange=stateChanged;
  23. obj.open("GET","ajaxex.aspx?client="+ document.getElementById("DropDownList1").value,true);
  24. obj.send(null);        
  25. }
  26. return false;
  27. }
  28.  
  29. function stateChanged() 
  30. var obj;
  31. if (obj.readyState == 4)
  32. var textclient=obj.responseText;
  33. alert(textclient);
  34. var textclientobj=document.getElementById("TextBox1");
  35. textclientobj.innerHTML=textclient;
  36.  
  37. }
  38. }
  39. </script>
  40.  
ajaximp.aspx.cs:
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.  
  4.         DropDownList1.Attributes.Add("onChange", "return GetDataViaAJAX();");
  5.         }     


Plz give me a solution.its urgent!!!!

Thaks
Krish
Oct 16 '07 #1
Share this Question
Share on Google+
3 Replies


kenobewan
Expert 2.5K+
P: 4,871
Here is an article that may help:
AJAX for ASP.NET
Oct 16 '07 #2

P: 1
Hello krishnagovindaraj,

I know it is too late reply. Since just now I come across your question and thought of helping you. To avoid your issue remove variable declaration for "obj" from onstate function and check.
Mar 31 '09 #3

Plater
Expert 5K+
P: 7,872
Well this was a really simple answer, not sure why its being brought up
Of course readyState doesn't exist, obj is a null object in this instance
Expand|Select|Wrap|Line Numbers
  1. var obj; 
  2. if (obj.readyState == 4) 
  3. {  
  4.  
Remove the var obj; line and it should be fine
Apr 1 '09 #4

Post your reply

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