[Fiddler] Error:Content-Length mismatch: Request Header indicated 16 bytes, but client sent 0 bytes.

来源:互联网 发布:淘宝运营策划方案 编辑:程序博客网 时间:2024/06/04 18:08

[Fiddler] Error:Content-Length mismatch: Request Header indicated 16 bytes, but client sent 0 bytes.

 

The error is because of do "location.reload();" after "$.ajax()".

Remove "location.reload();" will fix the issue.

 

 $.ajax({                type: 'POST',                url: pageUrl,                data: JSON.stringify(parameter),                contentType: 'application/json; charset=utf-8',                dataType: 'json',                success: function (data) {                    onSuccess(data);                },                error: function (data, success, error) {                    alert("Error : " + error);                }            });

 

Another same cause error:
2299 Failed to obtain request body. System.IO.InvalidDataException The request body did not contain the specified number of bytes. Got 0, expected 19

 

So how to do refresh page after ajax:

$.ajax({                type: 'POST',                url: pageUrl,                data: JSON.stringify(parameter),                contentType: 'application/json; charset=utf-8',                dataType: 'json',                success: function (data) {                    onSuccess(data);                },                error: function (data, success, error) {                    alert("Error : " + error);                },                complete: function () {                    setTimeout(function () {                        window.location.reload();                    }, 1000);                }            });


 

0 0
原创粉丝点击