1.去掉首尾空格
$('.show #answer').val().toString().trim()
2.把换行符换为<br>
str.split('
').join('<br>')
3.把数字转换为大写字母
function change(t){
if(t >= 0 && t <= 26){
var i=parseInt(t);
return String.fromCharCode(65 + i);
}
}
console.log(change(0));//A
console.log(change(1));//B
console.log(change(2));//C
console.log(change(3));//D
console.log(change(4));//E
console.log(change(5));//F
4.向后台传输数据
$.ajax({
url : '/api/v1/questionnaire/submit',
type : 'POST',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(Obj),
success:function(data){
console.log(data);
if(data.code == 0){
//写你的操作
}
}
})