Structure:
Index.html ---> ajax. js
Dispatch. php ----> addclassify. php -----> database. php
After index.html is opened, the page is displayed normally. Both Chinese and English are OK. Click Add. ajax. js sends the request to dispatch. dispatch is distributed to addclassify according to the request function code. This file is added and will use the functions in database. php. Then addclassify returns the result with echo. OK is returned for successful addition, and the error cause is returned for failed addition.
Strange things happen, and ajax always returns garbled characters.
Previously garbled characters were caused by inconsistent communication codes. However, my index. heml is UTF-8 and ajax is UTF-8. The default Character Set of php. ini is utf8.
Previously there was an html and php architecture, but the two programs run normally.
I woke up and thought of another possibility. This dispatch. php is garbled during storage on the server.
Ssh connection, vim, I see, x, your mom, html files are normal, all PHP files contain Chinese characters are garbled.
In windows, I use zend stuio to write php and dreamweaver to write html. That is to say, dreamweaver stores the webpage as utf8, and zend stuidio does not. Because the PHP file written by zend studio is saved as ANSI, Chinese characters are garbled after being uploaded to the server.
Temporary solution: open all the PHP files written by zend in notepad, and select UTF-8 when saving the files. OK.
Ultimate Solution: Modify zend studio settings. I use zend studio 9. The setting options may vary in different versions, and readers can find them by themselves.
Toolbar: project -----> properties in this window to see the Resource, modify the text file encoding to the UTF-8, save it.
Test:
Create a file 1.php in the project and enter the following code
1. <? Php
2. echo "Neural Network, Sha, 3, and so on ";
3.?>
Running result:
OK
From the boundless ocean of shyandsy