Structure: After renewal, the page is displayed normally. both Chinese and English are OK. Click Add. ajax. js sends the request to dispatch, and dispatch distributes the request to addcl according to the request function code.
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.
2. echo "neural network, Sha, 3, and so on ";
3.?>
Running result:
OK
From the boundless ocean of shyandsy