.ajax POST sending wrong content type
I'm running into a prob with an ajax form post where the content type is being sent to the server as text/html instead of text/javascript... here's some of my code:
I do this at the top of my .js file -
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})
I have 2 pieces of code for 2 diff fxns... the first works fine... the second posts with the wrong type -
GOOD:
$(".request_email_select").change(function(event) {
$.ajax({
type: "POST",
url: $(this).attr('select_email_path'),
data: { value: val, id: $(this).attr('request_id') },
success: function(html){
$(this).html(html);
}
});
$(".request_email_select").change(function(event) {
BAD:
$('#new_email_submit').click(function () {
$.ajax({
type: "POST",
url: $(this).attr('form_action'),
data: { address: $('input[name=address]'), id: $(this).attr('request_id') },
success: function(html){
$("#request_email_" + $(this).attr('request_id')).html(html);
}
});
$('#dialog_form').jqmHide();
//cancel the submit button default behaviors
return false;
});
I cant figure out what is wrong with the second one... it looks the right and the same as the first, but it aint working... does anybody see something wrong or have a suggestion?
I've also tried a .post call to see if that made a diff, but I got the same, so maybe it's not in the jQuery code...?