Bug Tracker


Ticket #6549 (closed enhancement: worksforme)

Opened 4 years ago

Last modified 3 years ago

AJAX calls should set the "Accept" header if appropriate

Reported by: MikeBaranczak Owned by:
Priority: undecided Milestone:
Component: ajax Version: 1.4.2
Keywords: ajax header json Cc:
Blocking: Blocked by:


Some web service libraries (like Jersey) allow you to send back data in different formats (like XML, JSON or www-form-encoded) from the same URL. The client can select the format by setting the "Accept" request header. This unfortunately can't be done through JQuery.

I propose the following enhancements:

  1. Allow the "Accept" header to be set when calling $.ajax();
  1. Make $.getJSON() (and possibly other high-level AJAX calls) set this header to the appropriate value by default.

(See the comment by Wolfram Arnold on this page:  http://api.jquery.com/jQuery.getJSON/ )

Change History

comment:1 Changed 4 years ago by MikeBaranczak

Sorry, please disregard this ticket. It turns out that JQuery already does set the "Accept" header.

comment:2 Changed 4 years ago by MikeBaranczak

OK, it looks like this is actually a bug that only appears in some situations. It happens when the URL contains a parameter: 'callback=?' - I haven't seen it happen otherwise. Someone who knows more about JSONP than me should probably review this.

comment:3 Changed 4 years ago by MikeBaranczak

This ticket is a duplicate of #6551.

comment:4 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:5 Changed 3 years ago by snover

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to worksforme

Setting dataType sets the Accept header.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.