1.        jquery的ajax()函数

1    $.ajax({               
2                 type: "POST",               
3                 dataType: "text",   
4                 url: "../../tools/submit_ajax.ashx?action=check_newstitle&> encodeURI(encodeURI(obj.value)),                    
5                success: function (result) { }

 

encodeURI两次编码,记住一定是两次,在后台action里要对取得的字符串进行decode

 

2.ajax配置contentType属性,加上charset=UTF-8   在ajax方法中加入以下参数   contentType: “application/x-www-form-urlencoded; charset=UTF-8″使用其它js框架或者xhr都是差不多,设置header中contentType即可,   

这里关键是charset=UTF-8,如果没有这个,是不行的,默认jQuery里的contentType是没有的

相关文章:

  • 2021-11-02
  • 2022-12-23
  • 2021-07-05
  • 2022-01-18
  • 2021-11-01
  • 2021-12-25
  • 2021-12-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
相关资源
相似解决方案