jquery-ajax-json: $.post(), $.ajax() and “??”

If you are posting JSON data, and, if the data may contain ‘??’, the $.ajax() should be used.
$.post() has a bug which will replace the first ‘??’ to an internal type identifier.

    type: “POST”,
    contentType: “application/json; charset=utf-8″,
    dataType: “json”,
    url: serverUrl,
    data: stringifiedJSON,
    success: function (data, status, xhr) {
      // succeeded.
  .fail(function(xhr, status) {
    // failed.
  .always(function(xhr, status) {
    // always to be executed.

the related bug@jquery.com

Leave a Reply