我在js里执行eval(tempstr);
tempstr的值是
"top.fight("{"aged":0,"aplayerid":10000,"attackdata":0,"attackdesc":"<font color='#CC0066'>你好。<\/font>","deadstr":"0","dedata":0,"fighthtml":"10000,流氓,\/Images\/tempImages\/random12.gif,NPC","mattri":{"pcinner":0,"pclife":5679,"pinner":3818,"plife":3408,"pminner":4032,"pmlife":5679},"otherinner":0,"pattri":{"pcinner":0,"pclife":21696,"pinner":1459,"plife":21594,"pminner":1791,"pmlife":21696}}");"
服务端生成的过程是
serializer = new DataContractJsonSerializer(typeof(FightShowInfo));
                    stream = new MemoryStream();
                    serializer.WriteObject(stream, pShowInfo);
                    stream.Position = 0;
                    sr = new StreamReader(stream);
                    Result = sr.ReadToEnd();
Result是传到客户端的值求解

解决方案 »

  1.   

    注意转义符,输出到客户端应该是"top.fight({\"aged\":0,\"aplayerid\":10000,\"attackdata\":0 ....省略...})"
      

  2.   

    你最好能在调试器里看看tempstr到底是什么,然后就知道为什么错了
      

  3.   

    后台是top.fight({\"aged这样传过去的,但是客户端接收了以后自动变成top.fight({"age了
      

  4.   

    后台是top.fight({\"aged这样传过去的,但是客户端接收了以后自动变成top.fight({"age了后台就传top.fight({\\"aged 过去就好了, \"被转义了
      

  5.   

    算了,我最后是只把top.fight去掉,在前台再加上,转义多了bug很多