Forum: Ruby on Rails jquery + setting accept header question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Steve O. (Guest)
on 2009-01-29 23:43
(Received via mailing list)
I've got a rails app and am using facebox to submit ajax forms. If I
submit the form in an inline manner (eg. not facebox) the form works
properly and the div gets updated.

However, if I submit the form in a facebox, the accept headers are
html and not javascript, and the response is handled in a html manner
(eg. the user is redirected to another page).

My question is what am I missing where the accept header on the
facebox forms is not being set to text/javascript?

Here's my js:

      var options = {
           target:   'form#message_form'
          // beforeSubmit doesn't work for either a facebox form
request or
inline form.
          // beforeSubmit: function(xhr) {xhr.setRequestHeader

            function() { $j(this).ajaxForm(options)}

// add Accept:text/javascript header to jQuery ajax requests
$j.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader
("Accept", "text/javascript")} })


This topic is locked and can not be replied to.