469,649 Members | 1,202 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

Object Expected Error

renji1981
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
5 1053
Dormilich
8,652 Expert Mod 8TB
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
@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
8,652 Expert Mod 8TB
it's a typo again:
line #22: XMLHttpRequestObject.readyState

note: unbeatable for debugging: Firebug plugin for Firefox
Jan 18 '09 #4
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
8,652 Expert Mod 8TB
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.

Similar topics

4 posts views Thread by Bill | last post: by
2 posts views Thread by jsnX | last post: by
11 posts views Thread by westplastic | last post: by
26 posts views Thread by yb | last post: by
12 posts views Thread by Andrew Poulos | last post: by
4 posts views Thread by loserdude84 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.