jq 获取表单未提交数据

jquery form表单.serialize()序列化后中文乱码问题原因及解决

原因:.serialize()自动调用了encodeURIComponent方法将数据编码了
解决方法:调用decodeURIComponent(XXX,true);将数据解码
例如:
var params = jQuery("#formId").serialize(); // http request parameters.
params = decodeURIComponent(params,true);


$("form").serialize() 可以获取form为提交数据, 其中里面中文默认被转码

decodeURIComponent($("form").serialize(), true) 解码中文表单数据

猜你喜欢

转载自blog.csdn.net/bushiyao_/article/details/52330302
jq
今日推荐