Capitalize first letter of string on json sending
This question already has an answer here:
You can use following function to capitalise any string (source)
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
Here, first character is changed to uppercase using string.charAt(0).toUpperCase()
and rest is changed to lower case. You can use this function to modify your request like following.
source: function( request, response ) {
request.term = capitalizeFirstLetter(request.term)
...
I haven't tested this out, but it should work ok.
链接地址: http://www.djcxy.com/p/17866.html上一篇: 首字母大写,其余小写
下一篇: 在json发送时大写首字母的字符串