Skip to main content

Bug Tracker

Side navigation

#10534 closed bug (invalid)

Opened October 19, 2011 01:58PM UTC

Closed October 19, 2011 03:05PM UTC

Last modified March 14, 2012 07:57AM UTC

POST Ajax and contentType sends no data.

Reported by: wildpeaks Owned by:
Priority: low Milestone: None
Component: ajax Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:

It seems that data is not sent if type POST is used and contentType is specified, however it works with GET.

Both 1.6.4 and 1.7 beta 2 behave the same way, so I'm not sure if this is by design.

Files used in the examples:

  • "index.html" is the page that uses jQuery.
  • "echo.php" prints as JSON the method and data it receives.

Source of echo.php:


print json_encode(
		'method' => $_SERVER['REQUEST_METHOD'],
		'request' => $_REQUEST


Source of index.html:


	<input id="get-without" type="button" value="GET: WITHOUT contentType" />
	<input id="get-with" type="button" value="GET: WITH contentType" />

	<input id="post-without" type="button" value="POST: WITHOUT contentType" />
	<input id="post-with" type="button" value="POST: WITH contentType" style="color: red" />

	<script src=""></script>
	<!--<script src=""></script>-->

		function send(type, contentType){
			var options = {
				type: type,
				dataType: "json",
				url: "echo.php",
				data: { 
					hello: "world"
				success: function(response){
			if (contentType) options.contentType = "application/json; charset=utf-8";

				send("get", false);
				send("get", true);
				send("post", false);
				send("post", true);


Attachments (0)
Change History (1)

Changed October 19, 2011 03:05PM UTC by timmywil comment:1

component: unfiledajax
priority: undecidedlow
resolution: → invalid
status: newclosed

I don't think this is an issue with jQuery. The data should be a valid json string if that is the contentType being used. In this case, I don't think sending the contentType is necessary.