Error handling for the API and restart again from same the point

I used to build apps like that and then I came up with a little framework that has helped me a lot: Single-page application framework: App Shell [free tutorial]

My tutorials are based on the old engine, but the principles still hold. @neilpierce has a more up to date one: