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

Object Expected Error

renji1981
P: 8
Hi Pals

Im getting Object Expected Error and Im new to Ajax . I have pasted the Html code here .. please help .

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head> 
  3. <title>My first ajax Application </title>
  4. <script language="javascript">
  5. var XMLHttpRequestObject =false;
  6. if(window.XMLHttpRequest)
  7. {
  8. XMLHttpRequestObject = new XMLHttpRequest();
  9. }
  10. else if(window.ActiveXObject)
  11. {
  12. XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  13. }
  14. funtion getdata(datasource , divid)
  15. {
  16. if (XMLHttpRequestObject)
  17. {
  18. var obj = document.getElementById(divid);
  19. XMLHttpRequestObject.open("GET",datasource);
  20. XMLHttpRequestObject.onreadystatechange = funcion()
  21. {
  22. if (XMLHttpRequestObject.readystate ==4 && XMLHttpRequestObject.status ==200)
  23. {
  24. obj.innerHTML = XMLHttpRequestObject.responseText;
  25. }
  26. XMLHttpRequestObject.send(null);
  27. }
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. <form>
  33. <input type ="button" value="Click here " onclick="getdata('data.txt','target')">
  34. </form>
  35. <div id = "target">
  36. Hi this is just a test
  37. </div>
  38. </html>
  39.  
the data file is in the same folder as the html file is and just contains some basic text
do reply to[edit]
Jan 18 '09 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
there are some typos creating havoc:
line #4 better use the type attribute
line #14 the keyword is "function"
line #20 (same as line #14)
Jan 18 '09 #2

renji1981
P: 8
@Dormilich

thanks for the reply ...there is no error now . but it is not loading the file contents which i have in the Data.txt file .My first ajax Application ... can you please check it
Jan 18 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
it's a typo again:
line #22: XMLHttpRequestObject.readyState

note: unbeatable for debugging: Firebug plugin for Firefox
Jan 18 '09 #4

renji1981
P: 8
Thanks a lot ... Works Perfect Now .... Really appreciate the Quick response from this site .. i waited 2 days in another site and dint get get even 1 replies . Thanks to the Moderators
Jan 18 '09 #5

Dormilich
Expert Mod 5K+
P: 8,639
I'm pleased about such a praise, nevertheless we're here to help (Experts, Members (and Moderators))
Jan 18 '09 #6

Post your reply

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