Bug Tracker

Changes between Version 1 and Version 2 of Ticket #13758, comment 3


Ignore:
Timestamp:
Apr 9, 2013, 1:06:49 PM (8 years ago)
Author:
KiranKumarT
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13758, comment 3

    v1 v2  
    11The link that I have provided do have fiddler information also.
    22
    3 But for reference I am again providing it here.
     3But for reference I am again providing it here.[[BR]]
    44
    5 When I have this code
     5When I have this code[[BR]]
    66
    7 $.ajax({
    8     type: 'POST',
    9     //contentType: "application/json",
    10     url: 'http://localhost:16329/Hello',
    11     data: { name: 'norm' },
    12     dataType: 'json'
    13 });
     7$.ajax({[[BR]]
     8    type: 'POST',[[BR]]
     9    //contentType: "application/json",[[BR]]
     10    url: 'http://localhost:16329/Hello',[[BR]]
     11    data: { name: 'norm' },[[BR]]
     12    dataType: 'json'[[BR]]
     13});[[BR]]
    1414
    15 in Fiddler I can see following raw request
     15in Fiddler I can see following raw request[[BR]]
    1616
    17 POST http://localhost:16329/Hello HTTP/1.1
    18 Host: localhost:16329
    19 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
    20 Accept: application/json, text/javascript, */*; q=0.01
    21 Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
    22 Accept-Encoding: gzip, deflate
    23 Connection: keep-alive
    24 Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    25 Referer: http://localhost:14693/WebSite1/index.html
    26 Content-Length: 9
    27 Origin: http://localhost:14693
    28 Pragma: no-cache
    29 Cache-Control: no-cache
     17POST http://localhost:16329/Hello HTTP/1.1[[BR]]
     18Host: localhost:16329[[BR]]
     19User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101
     20Firefox/10.0.2[[BR]]
     21Accept: application/json, text/javascript, */*; q=0.01[[BR]]
     22Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3[[BR]]
     23Accept-Encoding: gzip, deflate[[BR]]
     24Connection: keep-alive[[BR]]
     25Content-Type: application/x-www-form-urlencoded; charset=UTF-8[[BR]]
     26Referer: http://localhost:14693/WebSite1/index.html[[BR]]
     27Content-Length: 9[[BR]]
     28Origin: http://localhost:14693[[BR]]
     29Pragma: no-cache[[BR]]
     30Cache-Control: no-cache[[BR]][[BR]]
    3031
    31 name=Kiran
     32name=Kiran[[BR]][[BR]]
    3233
    33 But what I'm trying is to set content-type from application/x-www-form-urlencoded to application/json. But this code
     34But what I'm trying is to set content-type from application/x-www-form-urlencoded to application/json. But this code[[BR]]
    3435
    35 $.ajax({
    36     type: "POST",
    37     contentType: "application/json",
    38     url: 'http://localhost:16329/Hello',
    39     data: { name: 'norm' },
    40     dataType: "json"
    41 });
    42 Generates strange request (which I can see in Fiddler)
     36$.ajax({[[BR]]
     37    type: "POST",[[BR]]
     38    contentType: "application/json",[[BR]]
     39    url: 'http://localhost:16329/Hello',[[BR]]
     40    data: { name: 'norm' },[[BR]]
     41    dataType: "json"[[BR]]
     42});[[BR]]
     43Generates strange request (which I can see in Fiddler)[[BR]]
    4344
    44 OPTIONS http://localhost:16329/Hello HTTP/1.1
    45 Host: localhost:16329
    46 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
    47 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    48 Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
    49 Accept-Encoding: gzip, deflate
    50 Connection: keep-alive
    51 Origin: http://localhost:14693
    52 Access-Control-Request-Method: POST
    53 Access-Control-Request-Headers: content-type
    54 Pragma: no-cache
    55 Cache-Control: no-cache
    5645
    57 In the first inputs If I get Content-Type: application/json; charset=UTF-8 instead of Content-Type: application/x-www-form-urlencoded; charset=UTF-8
     46OPTIONS http://localhost:16329/Hello HTTP/1.1[[BR]]
     47Host: localhost:16329[[BR]]
     48User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2[[BR]]
     49Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[[BR]]
     50Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3[[BR]]
     51Accept-Encoding: gzip, deflate[[BR]]
     52Connection: keep-alive[[BR]]
     53Origin: http://localhost:14693[[BR]]
     54Access-Control-Request-Method: POST[[BR]]
     55Access-Control-Request-Headers: content-type[[BR]]
     56Pragma: no-cache[[BR]]
     57Cache-Control: no-cache[[BR]][[BR]]
     58
     59In the first inputs If I get Content-Type: application/json; charset=UTF-8 instead of Content-Type: application/x-www-form-urlencoded; charset=UTF-8[[BR]]
    5860
    5961Then every thing will work properly.