Jquery validation plugin remote query - error/failure handling?

Up vote 2 down vote favorite share g+ share fb share tw.

I'm using the jquery validation plugin on a user profile editing form. I'm using the 'remote' feature to query my website and check email uniqueness, which is working well. My question is about how to deal with errors or failures, which doesn't seem to be well documented.

The behaviour I want is that if the JSON query fails or times out forget this part of the validation, allow the user to submit and let the server side validation take care of it. I can see there is an error attribute, and it looks like you can add a function to run in that scenario, but what would I put there to switch off the validation rule in case of timeout/error/failure? Remote: { url: location.

Pathname + "/EmailUnique", timeout: 20000, data: { userID: function() { return $("#Form_EditProfileForm_userID").val(); } } } jquery validation timeout remote link|improve this question asked Jan 31 at 18:44user1181064132.

Yes, add an error function: remote: { //your normal $. Ajax stuff here , error: function(jqXHR, textStatus, errorThrown) { //deal with the error } } All of these parameters are passed to a normal jQuery ajax call, so by specifying an error function, you get to handle whatever happens. Assuming you've saved your validation object in a variable v, your error function could be this simple: $('#inputWithRemote').

Rules('remove','remote');. V. PendingRequest--; Honestly, the v.

PendingRequest business is to deal with what I would call a bug in the Validation plugin - it increments this pendingRequest counter when it kicks off the ajax request, but doesn't have it's own code to deal with errors in the response. See it in action here: http://jsfiddle.net/ryleyb/H96TD/ (note that I've set the timeout to 2 seconds and used some of jsfiddle's special ajax code to force the response to take 3 seconds).

Thanks for this response, I've only just checked back to implement something but I'll use this later in the week. – user1181064 Feb 20 at 21:02 1 That's alright, it's a good question either way - people should deal with errors in ajax, and it's not obvious what happens with this plugin in that case... – Ryley Feb 20 at 21:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions