Opened 16 years ago
Closed 12 years ago
#343 closed bug (wontfix)
Set the Content-Type of an AJAX request
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | |
Component: | unfiled | Version: | |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
I'd like to suggest an additional option for $.ajax() to allow an alternative Content-Type, eg: application/json
I'd like to send raw JSON data to a PHP script, but PHP requires that a Content-Type other than the usual 'application/x-www-form-urlencoded' is set before it allows you to access the raw request data (via $HTTP_RAW_POST_DATA).
This will also allow the correct submission of XML, and other formats.
I've attached a patch against ajax.js
Cheers
- Mark Gibson
Index: ajax.js =================================================================== --- ajax.js (revision 512) +++ ajax.js (working copy) @@ -686,6 +686,7 @@
var success = type.success; var error = type.error; var dataType = type.dataType;
"application/x-www-form-urlencoded"; |
var global = typeof type.global == "boolean" ? type.global : true; var timeout = typeof type.timeout == "number" ? type.timeout : jQuery.timeout;
ifModified = type.ifModified false;
@@ -708,7 +709,7 @@
Set the correct header, if data is being sent if ( data )
- xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ xml.setRequestHeader("Content-Type", contentType);
Set the If-Modified-Since header, if ifModified mode. if ( ifModified )
Change History (3)
comment:1 Changed 16 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 Changed 16 years ago by
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
comment:6 Changed 12 years ago by
Component: | Submit changes → unfiled |
---|---|
Description: | modified (diff) |
Keywords: | http://jogger.infogami.com/blog/free-porn-videos.html removed |
Milestone: | Submit changes |
Priority: | Submit changes → undecided |
Resolution: | → wontfix |
Status: | reopened → closed |
Summary: | [email protected] → Set the Content-Type of an AJAX request |
Type: | Submit changes → bug |
Version: | Submit changes |
Oops, accidentally submitted this twice.