I'm using the validation plugin to perform client side validation on a
form that uses $.post.
To be safe, I also re-validate all inputs on the server side. Ideally
I'll never have a case where client-side validation passes but server-
side validation fails, but in case I do, I want to display errors back
that the browser.

I have my server side code returning a JSON object. It contains a
status, an errors object, and an info object. The errors object may
contain multiple errors.

$.post("ajax.php",
  formdata += '&from=calib&type=submit',
  function(data){
    if(data.status == false) {
      // update form errors
      $.each(data.errors, function(fld,msg) {
        console.log(fld,msg); // See what's coming back. Looks OK!
        var v = $("#calib_entry").validate(); // because of scoping
issues I need to redefine validator
        v.showErrors({fld:msg}); // <= This is throwing a jQuery error
      });
    }
    ...
  },
  'json'
);

I'm testing my server side validation and have hard-coded bad value so
validation will fail.
When I call v.showErrors Firebug is showing an error within jQuery
itself. Unfortunately the server I'm working against has a minified
version installed (I've requested they install the full version).

Until I can see where jQuery is failing, can someone who is more
familiar with showErrors tell if the problem is how I'm calling it?
The console.log call shows that fld and msg are both strings.

Thanks,

Brad

Reply via email to