This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chrisiek
chrisiek

I my onUpdate handler, during processing data, I found an error and I want to stop processing and display this message

 error:"show_notify_msg('error','Updating account failed.')"

How should I do it? Throwing exception or anything else it always gives me the success message.

{{ form_ajax('onUpdate', { 
    confirm: 'Do you really want to update this record?', 
    success:"show_notify_msg('success','Updating succeeded.')", 
    error:"show_notify_msg('error','Updating failed.')"
}) }}

Last updated

DMeganoski
DMeganoski

Well, I've not used the form_ajax function before, but I have used the $.request() function of the ajax api. I believe I read somewhere that ajax will always return a 200 response code despite there being an exception thrown. I believe there is something in the json returned that will clue you in to the exception, and I would tell you to dump the response but it doesn't seem to pass it in the form_ajax function.

You can find the response in the console of your browser. Here you can verify the response code it is returning.

can you use a callback for success and try logging the parameters it is given?

I.E.


{{ form_ajax('onUpdate', {
    confirm: 'Do you really want to update this record?',
    success: "function(response) { console.log(response); }",
    error:"show_notify_msg('error','Updating failed.')"
}) }}

I doubt this will work, but worth a shot.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.