New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback only runs on 200 response #215
Comments
I'm proposing a solution like this: performAjax = function() {
var xhr;
xhr = $.ajax({
type: options.type || 'GET',
url: options.url,
data: {
_method: options.method,
gon_return_variable: true,
gon_watched_variable: name
}
});
return xhr.done(callback).fail(errorCallback);
}; And then: gon.watch = function(name, possibleOptions, possibleCallback, errorCallback) {
var callback, errorCallback, key, options, performAjax, timer, value, _base, _ref;
if (typeof $ === "undefined" || $ === null) {
return;
}
... |
Hello! Thank you for issue. Can you do a PR? |
@gazay Sure, I can work on this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm not sure if this is an issue, maybe it's a feature request.
gon
is working fine and calling mycallback
when the response is 200 (OK) but it's not calling it when I get response different than 200.The problem is that we are relying on
done
to call the callback which only works with successful responses: https://github.com/gazay/gon/blob/master/js/watch.js#L36I'm wondering if we could have another callback (e.g.
errorCallback
)What do you think?
Thanks
The text was updated successfully, but these errors were encountered: