ss27588709 2014-12-17 02:01 采纳率: 100%
浏览 3790
已采纳

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"},

求各位大神帮忙支招。

  • 写回答

5条回答 默认 最新

  • ss27588709 2014-12-19 02:53
    关注

    有时候数据还是这样的

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 关于#linux#的问题(输入输出错误):出现这个界面接着我重新装系统,又让修电脑的师傅帮我扫描硬盘(没有问题)用着用着又卡死(相关搜索:固态硬盘)
  • ¥15 cv::resize不同线程时间不同
  • ¥15 web课程,怎么做啊😭没好好听课 根本不知道怎么下手
  • ¥15 做一个关于单片机的比较难的代码,然后搞一个PPT进行解释
  • ¥15 python提取.csv文件中的链接会经常出现爬取失败
  • ¥15 数据结构中的数组地址问题
  • ¥15 maya的mel里,怎样先选择模型A,然后利用mel脚本自动选择有相同名字的模型B呢。
  • ¥15 Python题,根本不会啊
  • ¥15 会会信号与系统和python的来
  • ¥15 关于#python#的问题