hobo_ajax_response with preamble - why the "ajax failed" message?

5 views
Skip to first unread message

Tim Griffin

unread,
Apr 24, 2017, 10:07:48 PM4/24/17
to Hobo Users
Hi all;

I have a quick question about using a preamble on a call to hobo_ajax_response. 

On a form, I have a <select> which is bound to a javascript function when it changes:

    $("#ctl_select").change(lts.updateDocumentFields);

In a controller, I have an unrelated web method that needs trigger this same function call when it's done. So, I thought I'd do this:

  def my_web_method
    ...
    ...
    js="lts.updateDocumentFields();"
    hobo_ajax_response( :postamble => js )
  end

While this actually works and does the job, it leaves an "ajax failed" message in the Chrome console. 

Instead, I find I've had to do the following to avoid the "ajax failed" message, but it feels more like a hack:

    # Trigger the change event manually to get updateDocumentFields to fire:
    js="$('#ctl_select_nature').change();"
    hobo_ajax_response( :postamble => js )

Anyone have an idea what the origin of the "ajax failed" message would be when I make a direct call to that javascript function instead of via the bound event? 

Any insight would be great.

Thanks!
Tim



Reply all
Reply to author
Forward
0 new messages