开发者社区> 问答> 正文

AJAX POST 字符串(长度400左右的JSON格式字符串)出现字符串在后台接收时混乱

前端 是HTML,通过AJAX异步调用,
其中masterString是将JSON格式的数组转换成string,(使用json2.js与自己写的jsonToString)均有问题。

$.ajax({
 url: "../Services/Service" + handletype + ".ashx",
 type: "post",
 dataType: "text",
 data: "add=fl&result=" + masterString + "&encoded=" + encodeURIComponent(masterString),
 async: true,
 success: function (data) {}
});

后台是.NET写的ashx的generic handler,后台捕获数据时发现:

 约5000次请求中会有1-2次数据异常,
key:add
 value:fl
 key:result
 value:{"MasterID":"7","UserOpenID":"","QAList":[{"Q":"733","A":"2072"},{"Q":"734","A":"2076"},{"Q":"735","A":"2079"},{"Q":"736","A":"2082"},{"Q":"737","A":"2085"},{"Q":"738","A":"2088"},{"Q":"739","A":"2091"},{"Q":"740","A":"2094"},{"Q":"741","A":"2097"},{"Q":"742","A":"2099"},{"Q":"743","A":"2103"},{"Q":"744","{"Q":"747","A":"2114"},{"Q":"748","A":"2119"},{"Q":"749","A":"2122"},{"Q":"750","A":"2123"},{"Q":"751","A":"2128"},{"Q":"752","A":"2129"},{"Q":"753","A":"2134"},{"Q":"754","A":"2137"},{"Q":"755","A":"2138"},{"Q":"756","A":"2142"},{"Q":"757","A":"2144"},{"Q":"758","A":"2148"},{"Q":"759","A":"2150"},{"Q":"760","A":"2151"},{"Q":"761","A":"2154"},{"Q":"762","A":"2158"},{"Q":"763","A":"2163"},{"Q":"764","A":"2168"},{"Q":"765","A":"2173"}]}
 key:encoded
 value:{"MasterID":"7","UserOpenID":"","QAList":[{"Q":"733","A":"2072"},{"Q":"734","A":"2076"},{"Q":"735","A":"2079"},{"Q":"736","A":"2082"},{"Q":"737","A":"2085"},{"Q":"738","A":"2088"},{"Q":"739","A":"2091"},{"Q":"740","A":"2094"},{"Q":"741","A":"2097"},{"Q":"742","A":"2099"},{"Q":"743","A":"2103"},{"Q":"744","A":"2106"},{"Q":"745","A":"2109"},{"Q":"746","A":"2112"},{"Q":"747","A":"2114"},{"Q":"748","A":"2119"},{"Q":"749","A":"2122"},{"Q":"750","A":"2123"},{"Q":"751","A":"2128"},{"Q":"752","A":"2129"},{"Q":"753","A":"2134"},{"Q":"754","A":"2137"},{"Q":"755","A":"2138"},{"Q":"756","A":"2142"},{"Q":"757","A":"2144"},{"Q":"758","A":"2148"},{"Q":"759","A":"2150"},{"Q":"760","A":"2151"},{"Q":"761","A":"2154"},{"Q":"762","A":"2158"},{"Q":"763","A":"2163"},{"Q":"764","A":":"2163"},{"Q":"764","A":"2168"},{"Q":"765","A":"2173"}]}

发现:
不进行encode在Q744处出现异常(异常位置随机,每次都不一样。){"Q":"744","{"Q":"747","A":"2114"},encode部分在764处异常,"Q": "764","A": ":"2163"},

求各位大神帮忙支招。

展开
收起
杨冬芳 2016-07-04 16:37:57 2242 0
1 条回答
写回答
取消 提交回答
  • IT从业

    有时候数据还是这样的

    FORM DATA: 
     key:
     value:FF�f�b'V7W�Gӷ"�7GV'�D"�"c"�"U7V'�V�D"�""�"Ė7G"���""�"cc�"�""�"�S#"�·""�"cs"�""�"�Sc"�·""�"cs"�""�"�c"�·""�"cs#"�""�"�c3"�·""�"cs3"�""�"�c�"�·""�"csC"�""�"�sC"�·""�"csS"�""�"�sS"�·""�"csc"�""�"�ss"�·""�"css"�""�"��"�·""�"cs�"�""�"��C"�·""�"cs�"�""�"���"�·""�"c�"�""�"��#"�·""�"c�"�""�"��s"�·""�"c�#"�""�"�"�·""�"c�3"�""�"�S"�·""�"c�C"�""�"��"�·""�"c�S"�""�"�#"�·""�"c�c"�""�"�S"�·""�"c�s"�""�"��"�·""�"c��"�""�"�#S"�·""�"c��"�""�"�#s"�·""�"c�"�""�"�3#"�·""�"c�"�""�"�3c"�·""�"c�#"�""�"�3�"�·""�"c�3"�""�"�Cc"�·""�"c�C"�""�"�Cs"�·""�"c�S"�""�"�S"�·""�"c�c"�""�"�SS"�·""�"c�s"�""�"�S�"�·""�"c��"�""�"�cS"���bV�6�FVF�Rs$R##�7GV'�DR##R3R##cR##R#4R##U7V'�V�DR##R3R##R##R#4R##Ė7GR##R3RS$Rs$R##R##R3R##cc�R##R#4R##R##R3R##�S#R##RsDR#4Rs$R##R##R3R##csR##R#4R##R##R3R##�ScR##RsDR#4Rs$R##R##R3R##csR##R#4R##R##R3R##�cR##RsDR#4Rs$R##R##R3R##cs#R##R#4R##R##R3R##863"},{"Q":"673","A":"1868"},{"Q":"674","A":"1874"},{"Q":"675","A":"1875"},{"Q":"676","A":"1877"},{"Q":"677","A":"1881"},{"Q":"678","A":"1884"},{"Q":"679","A":"1888"},{"Q":"680","A":"1892"},{"Q":"681","A":"1897"},{"Q":"682","A":"1901"},{"Q":"683","A":"1905"},{"Q":"684","A":"1908"},{"Q":"685","A":"1912"},{"Q":"686","A":"1915"},{"Q":"687","A":"1919"},{"Q":"688","A":"1925"},{"Q":"689","A":"1927"},{"Q":"690","A":"1932"},{"Q":"691","A":"1936"},{"Q":"692","A":"1939"},{"Q":"693","A":"1946"},{"Q":"694","A":"1947"},{"Q":"695","A":"1951"},{"Q":"696","A":"1955"},{"Q":"697","A":"1959"},{"Q":"698","A":"1965"}]}

    值不能为 null
    参数名: input

    2019-07-17 19:50:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载