acidglitter Posted May 19, 2008 Share Posted May 19, 2008 i'm really new to ajax so i'm not completely sure on the regular way to code things. this is what i have now to start an object: var object = false; if(window.XMLHttpRequest){ object = new XMLHttpRequest(); } else if(window.ActiveXObject){ object = new ActiveXObject("Microsoft.XMLHTTP"); } what i have been doing is using javascript to start a function, then putting that code at the beginning of the function to create the object. for each thing i'm using ajax for i have a new function and a new object created for it. should i just keep doing it that way? or would it be better to start the object at the top of the page, then have each function just use that object over and over again? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 19, 2008 Share Posted May 19, 2008 I'll say the same thing as I said a little while ago here: http://www.phpfreaks.com/forums/index.php/topic,197874.0.html Um, is there a reason you don't just use one of the many JS libraries already in existence? Why reinvent the wheel? A nice lite-weight one I use a lot is jQuery Quote Link to comment Share on other sites More sharing options...
acidglitter Posted May 19, 2008 Author Share Posted May 19, 2008 i'll try looking at their site, but like that other person said, i like trying to understand it all myself, and besides that, for me, just using someone elses code takes most of the fun out of programming for me. i like experimenting and editing every little detail Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 19, 2008 Share Posted May 19, 2008 Well, I will say, that if you use a global variable, you will have problems when an request is opened before the first is finished. As, it will overwrite the variable. Quote Link to comment Share on other sites More sharing options...
acidglitter Posted May 19, 2008 Author Share Posted May 19, 2008 this is probably a dumb question, but opening an object on your computer isn't affected by opening one on someone elses computer is it? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 19, 2008 Share Posted May 19, 2008 Nope Quote Link to comment Share on other sites More sharing options...
acidglitter Posted May 19, 2008 Author Share Posted May 19, 2008 well i'm looking at some jquery tutorials and its looking really interesting. i might actually end up using it for a couple of my sites and just edit or add a few things for now i think i'll just keep creating new objects with each function. thanks for the link Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.