在CentOS7上安装使用Ansibel(自动化工具)Install and use Ansible (Automation Tool) in CentOS 7
2016-04-02 08:10
976 查看
Q:
In my web app, i submit some form fields with JQuery
$.getJSON() Method. I am having some problems with the encoding. The
character-set of my app is charset=ISO-8859-1 but i think this fields
are submitted with UTF-8.
Does anyone know, how can i set encoding in $.getJSON calls?
A:
I think that you'll probably have to use $.ajax()
if you want to change the encoding, see the
param below (the
and
callbacks assume you have
and
in the html):
If you want to use $.getJSON() you can add the following before the call :
You can use the charset you want instead of utf-8.
contentType : When sending data to the server, use this content-type.
Default is "application/x-www-form-urlencoded", which is fine for most
cases.
scriptCharset : Only for requests with 'jsonp' or 'script' dataType
and GET type. Forces the request to be interpreted as a certain charset.
Only needed for charset differences between the remote and local
content.
You may need one or both ...
In my web app, i submit some form fields with JQuery
$.getJSON() Method. I am having some problems with the encoding. The
character-set of my app is charset=ISO-8859-1 but i think this fields
are submitted with UTF-8.
Does anyone know, how can i set encoding in $.getJSON calls?
A:
I think that you'll probably have to use $.ajax()
if you want to change the encoding, see the
contentType
param below (the
success
and
error
callbacks assume you have
<div id="success"></div>
and
<div id="error"></div>
in the html):
$.ajax({ type: "POST", url: "SomePage.aspx/GetSomeObjects", contentType: "application/json; charset=utf-8", dataType: "json", data: "{id: '" + someId + "'}", success: function(json) { $("#success").html("json.length=" + json.length); itemAddCallback(json); }, error: function (xhr, textStatus, errorThrown) { $("#error").html(xhr.responseText); } });
If you want to use $.getJSON() you can add the following before the call :
$.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"});
You can use the charset you want instead of utf-8.
contentType : When sending data to the server, use this content-type.
Default is "application/x-www-form-urlencoded", which is fine for most
cases.
scriptCharset : Only for requests with 'jsonp' or 'script' dataType
and GET type. Forces the request to be interpreted as a certain charset.
Only needed for charset differences between the remote and local
content.
You may need one or both ...
相关文章推荐
- (OK) centos7 编译 php-7.0.0RC5
- 基于CentOS6.7的DRBD安装配置过程详解
- Linux _pthread 属性的控制
- Linux_ pthread 线程的取消
- Linux _条件变量
- linux 安装Python 包
- Linux用户和用户组管理
- Linux中Shutdown命令实现定时自动关机 ---fwqlzz love is for ever
- 如何用LINUX命令格式化U盘 ---fwqlzz love is for ever
- linux kernel current宏
- linux的ACL
- Linux中搭建SVN服务器
- cmake记坑帖
- Linux中export导入环境变量的几种方式
- CentOS6.7网卡配置及常见问题(linux ip配置)
- deepin使用串口工具的使用方法
- Linux中vim编辑器莫名下方出现H的问题
- Linux系统如何创建一个新进程
- 编写Linux中sh文件执行时出现莫名字符的问题
- python在linux上的GUI无法弹出界面