AJAX截断" 00"字符串到" 0"

时间:2017-10-19 17:59:02

标签: c# asp.net ajax asp.net-ajax

所以我超过了" 00"使用ajax并且出于某种原因,当我的WebMethod收到字符串时,它只是" 0"我怎样才能确保这种截断不会发生?

$.ajax({
    url: 'http://localhost//Scripts/test.aspx/test',
    type: 'POST',
    data: JSON.stringify('{"tivId":"' +
        $(e.relatedTarget).data('id') +
        '","lotId":"' +
        <%= LotId() %> 
        '"}'),
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    success: function(response) {
        SetSuccessModal();
    },
    failure: function(response) {
        alert(response.d);
    }
});

2 个答案:

答案 0 :(得分:1)

尝试添加一些符号tru:

"|00|"

然后在webMethod中删除它们

param.replace("|","");

这是一个暂时的快速解决方案,当然,如果你能理解为什么会发生这种情况会更好。

除此之外,日期类型可能会导致问题,例如... int x = 00; //这将存储为0

答案 1 :(得分:-1)

没有任何代码就无法肯定地说,但字符串可能会在传输之前转换为某个整数。