Re: Form validation via AJAX

The parseerror was on the "console.log(status)" I believed was the "status"!
I'mm trying this:

  $("#new_pay_check").bind("ajax:complete", function(event, data, status, xhr) {
       console.log("data is -> " + data);
       $('#errorlist').html(data.text);
  });

And this is the output.

data is -> [object Object]

What is the attribute of the object to use? I don't know

Re: Form validation via AJAX

Sorry,  my bad,  the arguments are different between ajax:complete and ajax:success,

change it back it ajax:success, and get rid of the .text


$("#new_pay_check").bind("ajax:success", function(event, data, status, xhr) {
       console.log("data is -> " + data);
       $('#errorlist').html(data);
  });
Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Form validation via AJAX

But now we are coming back to the starting point.
With ajax:success I the function() isn't fired

Re: Form validation via AJAX

I found a solution
I'm using the ajax:complete then I check in the response if it is success (I found a way to inspect the object response)

  $("#new_pay_check").bind('ajax:complete', function(event, data, status, xhr) {
    if (data.status == 200) {
      $('#errorlist').html(data.responseText);
    }
  });

Re: Form validation via AJAX

If you care, I think I figured out why the success didn't fire.  I don't have a 3.X environment set up,  so I can't test it.

Instead of

render(:text=>xm.target!)

it should be

render(:js=>xm.target!)

If you put render(:text=>x) in a format.js block,  Rails says,  I'm expecting JavaScript,  but I'm returning text,  that's not right, so I won't consider the request a 'success'.

Just a theory really,  but if you want to do things the correct Rails way,  you may want to try it!

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Form validation via AJAX

Sorry to brake your hopes, it don't works smile
I think that the solution I found is acceptable, it costs only a more if statement.

I have another problem now, but I'm opening another post.