jQuery .ajax()方法,在IE 7上不能工作的数据中使用特殊字符



当我将特殊字符发送到数据参数但仅在Internet Explorer 7上时,我使用jQuery的.ajax方法有问题。它适用于ie8、ie9、Firefox和Chrome。

这里是代码的和平:

jqxhr = $.ajax({url: "/aj_search/", async: true, type: 'POST', dataType: 'json',
  data: decodeURIComponent($('#crit_form').serialize(true)),
  success: function(json){ // process code}
});

这是我发送的数据(当我打印decodeuriccomponent结果时):

小酒馆=小酒馆+ Manuelle& csrfmiddlewaretoken = ENFuL4ioBQ4nfkUESmkkAzNtHB7rhTKV& prix_min = 0, prix_max = 15,公里=,annee_min = 1989, annee_max = 2012, dpt =,模型=,= 1页,p_page = 10, sort_crit = weight& sort_dir = 1,比较=,is_comp = 0, ex_ma =, ex_mo =

问题出在 bo +Manuelle。当我打印我在django视图中得到的内容(服务器上接收到的数据)时,我得到:

Bo�te Manuelle

有什么想法吗?为什么这不能只在IE7上工作?

你应该不需要使用decodeURIComponent,无论如何,尝试删除它

try encodeuriccomponent instead

http://webdesign.about.com/od/localization/l/blhtmlcodes-ro.htm

这肯定对你有帮助。使用给出的代码代替特殊字符ok

最新更新