Closed cornae closed 10 years ago
@frontendplace , Does the above cover the problem space?
I suspect we can just enable jQuery global AJAX events for injection. Is there any reason that won't be sufficient?
At this time on 'no response', source or target not found only a log is registered in the console but no event is fired. it would be convenient if an event is fired and we could add an event handler on these events so we could display an error message and remove the inject class and can inform the user when the server responded different than expected. This is useful when you use an external service where you don't have access to the response sources. If an error occurred and no other response is expected the inject class must be removed. ( maybe as option)
Looking at the code I notice several things:
pat-ajax-error
is send when the server fails.pat-ajax-success
event triggered for successful XHR requests](https://github.com/Patternslib/Patterns/blob/master/src/pat/ajax.js#L76)It would be nice if the pat-ajax-error
and pat-ajax-success
events used a proper jQuery.Event object, but even right now they should already be usable.
if the source or target is not inside the response is there an event too? What I understand when I don't get a response I can use a listener to pat-ajax-error. when we get 500 or 503 error back do we get an pat-ajax-error back then too or success with source not found?
This ticket is about a generic server error, ie the XHR request failing. Looking at the source that is already covered: if the server responds with an error (and HTTP status codes 5xx or 4xx are errors) that will trigger the pat-ajax-error
event.
Errors regarding either the content of the response or not finding the injection point in the DOM are covered in issue #373.
great thanx
Sometimes there's no feedback at all from the server when using AJAX with pat-inject. It would be convenient to get an event when this is the case. A webdesigner/developer may then attach a certain behaviour such as a custom designed error message to this event.