jquery ajax post utf-16
HTML
<form action="http://jsfiddle.net/echo/json" method="post" id="create" accept-charset="UTF-8">
<input id="title" class="textfield cf" name="title" type="text" title="Title" value="中文" />
<input class="cf submit" name="create" type="submit" value="Publish" />
</form>
<p id="output"></p>
JavaScript
$(function() {
$('#create').submit(function() {
var inputs = [];
$('.cf', this).each(function() {
inputs.push(this.name + '=' + escape(this.value));
})
jQuery.ajax({
data: inputs.join('&'),
type: "POST",
url: this.getAttribute('action'),
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
timeout: 2000,
success: function(json) {
var r = jQuery.parseJSON(json);
$("#output").text(r);
}
})
return false;
})
});