Skip to main content

Bug Tracker

Side navigation

#6549 closed enhancement (worksforme)

Opened May 08, 2010 12:44AM UTC

Closed November 20, 2010 10:15PM UTC

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:
Blocked by: Blocking:
Description

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();

2. 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/ )

Attachments (0)
Change History (5)

Changed May 08, 2010 03:54AM UTC by MikeBaranczak comment:1

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

Changed May 10, 2010 02:54AM UTC by MikeBaranczak comment:2

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.

Changed May 10, 2010 03:22PM UTC by MikeBaranczak comment:3

This ticket is a duplicate of #6551.

Changed November 12, 2010 02:40AM UTC by snover comment:4

milestone: 1.4.3

Resetting milestone to future.

Changed November 20, 2010 10:15PM UTC by snover comment:5

priority: → undecided
resolution: → worksforme
status: newclosed

Setting dataType sets the Accept header.