get 方式提交数据到服务端不会乱码,但对数据量有限制;post 可以提交大数据量,但中文会发生乱码,解决方法:
在JS上用使用 encodeURIComponent 对字符编码处理:

 

   studentRuselt=encodeURIComponent(JSON.stringify(result),"utf-8"); //这里用了json2 来将对象转换为json格式,然后在用encodeURIComponent来设置编码;
  
   $.ajax({
             type:"post",
             url:"saveExamQuestionAnswer.action",
             cache:true,
             async:true, //这里指定值时不能加双引号(会设置无效)
             contentType: "application/x-www-form-urlencoded; charset=utf-8", 
             data: {
                studentRuselt: studentRuselt
             }
   )};

相关文章:

  • 2022-12-23
  • 2021-07-01
  • 2021-08-24
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
猜你喜欢
  • 2021-09-13
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案