-1

I try to pass parameters into aspx.cs page from js script. When I omit:

contentType: "application/json; charset=utf-8"

in ajax request I get by Request.Form["ORDER"] sth like {%7b%22ORDER_ID%22%3a126333%7d}. It means that this data comes to aspx.cs, but it is not decoded.

WITHOUT CONTENT TYPE

When I add contentType I get nothing in request.

WITH CONTENT TYPE

Below I attach request.

It is important to read parameters from Request.Form["ORDER"] in aspx.cs;

$.ajax({
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify({ ORDER_ID: orderKeyId }),
        dataType: "json",
        url: sUrl,
        success: function (data) {
            var s = 0;
        },
        error: function () {
            var s = 0;
        }
    });
gorrch
  • 521
  • 3
  • 16

1 Answers1

0

According to @Rory McCrossan comment, below ajax state worked:

$.ajax({
    type: 'POST',
    contentType: "application/x-www-form-urlencoded",
    data: "ORDER_ID=" + encodeURIComponent(orderKeyId),
    url: sUrl,
    success: function (data) {
        var s = 0;
    },
    error: function () {
        var s = 0;
    }
});
gorrch
  • 521
  • 3
  • 16