This is a migrated thread and some comments may be shown as answers.

SPA but only some S and error handling

2 Answers 76 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 30 Jan 2014, 11:40 AM
I'm creating my first SPA using Kendo and working through the examples. Everything is working great.

I am very interested with the concept that some 'views' do not have to be part of the SPA and can be 'fetched' from a remote resource and a quick test it works lovely.  BUT as a v experienced C++ programmer of 20 years+ I am
used to thinking in the negative i.e. what could go wrong and how can I make the app seeminglessly continue for the
user.  So my big concern is that the remote view.html will not be reachable (ether missing, bad url, network down etc). 

A quick test, by setting the href in the tabstrip <a> to a bad URL, and when I can click on the button the app then hangs.  Not good! See:

http://jsbin.com/iQUSuMI/1/edit

I would like to be able to catch/detect the error and show a message to the user or ideally show an alternative default View that I do have in the SPA already.



(FYI my app has to support branding and I am proposing that the 'About, Help and 'News' pages are fetched from my clients web servers as HTML, so my clients can update this information without having to go back to me to release app updates etc.  I could use a datasource instead but was interested in the error handling anyway)

2 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 30 Jan 2014, 12:48 PM
Further to the above I've just come across the Kendo samples and find the exact same bug/issue in the View example:

 '/examples/mobile/view/index.html' 

I click on 'Remote' which tries to load

 'file:///C:/dev/TAS_app/kendoui.complete.2013.3.1324.trial/examples/content/mobile/view/remoteview.html'

this fails because of CORS with error:
'XMLHttpRequest cannot load file:///C:/dev/TAS_app/kendoui.complete.2013.3.1324.trial/examples/content/mobile/view/remoteview.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.'


and the app hangs!

0
Accepted
Petyo
Telerik team
answered on 03 Feb 2014, 07:24 AM
Hi Paul,

In general, I would like to recommend that you load structured data instead of HTML UI chunks (remote views), especially if you expect flaky connection cases. This will allow for more responsive and smooth UI, as you can display placeholders and gradually fill them.

If you decide to stick with the current approach, you may look into the global ajax error handlers, exposed by jQuery. 

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
SPA
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or