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

Problem in ajax code like this.object is not defined

P: 2
Dear Friends ,

I am new in ajax .Follwoning code give error -

Expand|Select|Wrap|Line Numbers
  1.  
  2. var ajaxpack=new Object()
  3. ajaxpack.basedomain="http://"+window.location.hostname
  4. ajaxpack.ajaxobj=createAjaxObj()
  5. ajaxpack.filetype="txt"
  6. ajaxpack.addrandomnumber=0 //Set to 1 or 0. See documentation.
  7.  
  8. ajaxpack.getAjaxRequest=function(url, parameters, elemid, filetype){
  9. ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
  10. if (ajaxpack.addrandomnumber==1) //Further defeat caching problem in IE?
  11. var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
  12. if (this.ajaxobj){
  13. this.filetype=filetype
  14. this.ajaxobj.onreadystatechange=function()
  15. {
  16.       if(this.ajaxobj.readyState==4)
  17.         {
  18.         document.getElementById(elemid).innerHTML=this.ajaxobj.responseText;
  19.         }
  20.  
  21.  
  22. }
  23.  
  24. this.ajaxobj.open('GET', url+"?"+parameters, true)
  25. this.ajaxobj.send(null)
  26. }
  27. }
  28.  



Error: this.ajaxobj has no properties
Source File: http://localhost/ajax/ajaxroutine.js
Line: 39

line 39 is
if(this.ajaxobj.readyState==4)

i donot understand that why its give error because i am working on current object which is defined earlier .


Gunjan
May 4 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Can I see your createAjaxObj() function?

Mos likely you'll want to use ajaxpack.ajaxobj in place of this.ajaxobj.
May 4 '08 #2

P: 2
problem is solved when i use ajaxpack.ajaxobj in place of this.ajaxobj

Thank you for solving my problem


Gunjan
May 4 '08 #3

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad you got it working. Post again if you have more questions.
May 4 '08 #4

Post your reply

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