JQuery Ajax request for Chinese Character


Caleb Stack

Problem:

I have an auto-complete input which takes up Chinese character. However, when the user input Pin Yin partially, each English character is sent through although the chinese word is not completed yet.

Solution:

$(‘#input’).on(‘keyup’,function(e) {
var value = $(this).val(),
length = value.length,
lastChar = value.substring(length-1, length),
charCode = lastChar.charCodeAt(0);
if (charCode > 200) {// Take it}
});});

View original post