$.ajaxSetup --> contentType doesn't work
Using: JQuery 1.4.2.
Creating .Net app. Apparently it errors if i don't set the contentType. So I tried to set it in the ajaxSetup function, but it seems to reset it. The type and dataType attributes seem to work fine, though, just not the contentType.
- $(function () {
- $.ajaxSetup({ type: "POST", contentType: "application/json; charset=utf-8", dataType: 'json' });
- $(".refresh").click(function () {
- $.ajax(
- {
- //contentType: "application/json; charset=utf-8",
- url: 'json.aspx/GetRandomNumber',
- success: function (data) {
- $('.result').attr('value', data.d);
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- $('.result').attr('value', XMLHttpRequest + '-' + textStatus + '-' + errorThrown);
- }
- }
- );
- });
- });