简体   繁体   中英

jQuery code not passing special characters properly

I have a site that uses the jQuery jEditable plugin (inline editing via AJAX). Thing is, if you enter something like "Entrées" (this is for editing restaurant menus, so such input should be expected), the AJAX PHP script that gets the value instead receives "Entrées". How can I ensure the value being sent is sent properly?

What's even more weird is that the database value is stored as "Entrées", but when displayed on the web page, it displays "Entrées" properly.

Make sure not only the form where the text is entered but also the page where it's displayed use UTF8 encoding. If your "testing" to see what's received is a simple echo ...; exit; echo ...; exit; it's likely that this page is not rendered as UTF8.

发送之前,必须在字符串上使用javascript encodeURI()函数。

I think I may have solved the problem. Using escape() instead of encodeURI() worked properly. Anybody know why that would be?

escape() returned: Entr%E9es

encodeURI() returned: Entr%C3%A9es

Very strange.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM