Too much recursion 

Higher Order Javascript

 



   Subscribe in NewsGator Online    Subscribe in Rojo    Add to Google      Add to My AOL   Subscribe in FeedLounge   Add to netvibes  

Brendan Eich's Roadmap  Standard ECMA-262  www.schillmania.com  www.quirksmode.org 
www.snook.ca  www.davidflanagan.com  www.kryogenix.org  www.thomasfrank.se 
www.dustindiaz.com  Yahoo! UI Library  www.crockford.com  www.brainjacked.com 
chadlindstrom.ca  www.browserland.org     
       

Thursday, July 13, 2006

 

Almost ajax- Synchronous Javascript Remote Scripting


Ok, its time I started to do some

Ajax

(

Asynchronous JavaScript and XML

) type stuff. Why? Maybe it'll help get me a job. There are already so many libraries and good stuff out there, I'm not going to re-invent the wheel. In the next few weeks I'll look at some good/and/or/popular ajax 'suites'. I got my eye on a few obscure ones; I'll share these after I know what a bit more.
For today though, I needed a cross-domain solution for this app I'm making.
So here it is; its a bit of a hack but it works in the real world. Check the recursion out. Good for one use. Goes something like this:

// the php file which sends a javascript file has function myFunction
// var done is to keep track of setTimeout checks
doIt=function(){
this.done=0;
var s=document.createElement("script");
s.src="http://www.XX.com/js.php";
s.type='text/javascript'; s.id='loadScript';
document.body.appendChild(s);s=null;
doIt=function(){
this.done++; //alert("this.done = " + this.done);
if (this.done>15){return;} // number of setTimeout trys before forgetting it
if (functionFromJs.php){
alert('All Good');
//do stuff
}
else {setTimeout('doIt()',333);}
}
setTimeout('doIt()',333);
}

Comments:
Thank you for the efforts you been putting on making your site such an interesting and informative place to browse through.
 
I'm impressed, I must say. Very rarely do I come across a blog that's both informative and entertaining, and let me tell you, you've hit the nail on the head. Your blog is important; the issue is something that not enough people are talking intelligently about.


 
I’m completely enjoying as of it and that I have you ever bookmarked to ascertain out new stuff you'll post.. Can you also check


 
This is a very good post. Just wonderful. Truly, I am amazed at what informative things you've told us today


 
I really appreciate the kind of topics post here. Thanks for sharing us a great information that is actually helpful. Good day!


 
Post a Comment

Links to this post:

Create a Link



<< Home

Archives

June 2006   July 2006   August 2006   September 2006  

This page is powered by Blogger. Isn't yours?