# Jquery + setting accept header question

**URL:** <https://www.ruby-forum.com/t/jquery-setting-accept-header-question/158972>\
**Category:** Rails\
**Created:** [January 29, 2009, 10:43pm UTC](https://www.ruby-forum.com/t/jquery-setting-accept-header-question/158972 "2009-01-29T22:43:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [January 29, 2009, 10:43pm UTC](https://www.ruby-forum.com/t/jquery-setting-accept-header-question/158972/1 "2009-01-29T22:43:34Z")

</div>

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:  
#application.js  
$j(document).ready(function(){

```
  var options = {
       target: 'form#message_form'
      // beforeSubmit doesn't work for either a facebox form

```

request or  
inline form.  
// beforeSubmit: function(xhr) {xhr.setRequestHeader  
(“Accept”,  
“text/javascript”)}  
}

```
   $j('form#message_form').livequery(
        function() { $j(this).ajaxForm(options)}
    );

```

}

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

Thanks,

Steve
