I'm looking for a suggestion on how to deal with an error when fetching XML data for an instance.
I can do this for instance (forced error):
<xf:instance id="feed" src="https://httpbin.org/status/404"/>
And XSLTForms detects the issue and displays a modal error. However: I would like to deal with this error in user-friendly way.
So: I tried this - start with an empty model, and then perform a submission to fetch the data like this:
<xf:instance id="feed">
<channel xmlns="">
<title/>
<description/>
<image>
<url/>
</image>
<item/>
</channel>
</xf:instance>
<xf:submission id="load" replace="instance" instance="feed" resource="https://httpbin.org/status/404" method="get" serialize="none">
<xf:message level="modeless" ev:event="xforms-submit-error">
<xf:output value="'Error fetching data'"/>
</xf:message>
</xf:submission>
This works - but I had to tie the load to a button like this:
<xf:trigger id="t1">
<xf:label>LOAD</xf:label>
<xf:send ev:event="DOMActivate" submission="load"/>
</xf:trigger>
So - I click the button to (attempt) to load the data.
Questions:
- Instead of manually loading the data with the button - how to use the xforms-ready (if that is correct?) event to attempt the load automatically (so that it behaves like using 'src', but with custom error handling).
- Can I detect and display the actual response back from server? (so '404' or 'CORS' error etc?)