jquery validation plugin remote query - error/failure handling -



jquery validation plugin remote query - error/failure handling -

i'm using jquery validation plugin on user profile editing form. i'm using 'remote' feature query website , check email uniqueness, working well. question how deal errors or failures, doesn't seem documented. behaviour want if json query fails or times out forget part of validation, allow user submit , allow server side validation take care of it.

i can see there error attribute, , looks can add together function run in scenario, set there switch off validation rule in case of timeout/error/failure?

remote: { url: location.pathname + "/emailunique", timeout: 20000, data: { userid: function() { homecoming $("#form_editprofileform_userid").val(); } } }

yes, add together error function:

remote: { //your normal $.ajax stuff here , error: function(jqxhr, textstatus, errorthrown) { //deal error } }

all of these parameters passed normal jquery ajax call, specifying error function, handle whatever happens.

assuming you've saved validation object in variable v, error function simple:

$('#inputwithremote').rules('remove','remote');. v.pendingrequest--;

honestly, v.pendingrequest business deal phone call bug in validation plugin - increments pendingrequest counter when kicks off ajax request, doesn't have it's own code deal errors in response.

see in action here: http://jsfiddle.net/ryleyb/h96td/ (note i've set timeout 2 seconds , used of jsfiddle's special ajax code forcefulness response take 3 seconds).

jquery validation timeout

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -