Recently in the small program, in the test encountered a strange problem, the requested data can not be rendered, the data request was successful, but the page is not responding. Development tools, and the test on the Apple phone is good, there is a problem with Android, or the iOS system is more powerful. Out of the question, a face of the ignorant force, what to do! Search for a chant. Small program, just honestly on Baidu Bar. Enter ' applet Android render ', I go to really have, it seems to be the same as Android. Here's a picture for you to see, the problem is the same.
See this question and answer about the small program integrated community, estimated sorta, is the "\ufeff" problem, that is, the code is coding format problem, UTF8 and UTF8 no BOM. This problem is solved by others, it is not a problem at all. I also try, in this side of JS also like this filter, hemp eggs, small program jscore seems to not support str.replace (), direct error, the front this person feel a bit deceptive ah, do not say clearly, I will try to take the data at the back of the time to directly filter out the "\ufeff", Tried many times or not. Debugging is a waste of time, most of the time, godless the problem for a long time has not been resolved, we should properly put it put.
Later, finally in the small program integrated community found, can say the official answer: the official encryption data decryption algorithm PHP–SDK three files have with BOM head, to be removed. It's perfect, and here I'm documenting the ultimate solution.
Official explanation: Recently found similar problem is because the data returned is UTF-8 with the BOM (that is, the beginning of the data is a non-visible character Unicode 65279), the Android platform does not automatically filter, resulting in json.parse failure. Developers are now required to be self-compatible, and the next version of Android will filter this character.
Attached link: http://www.wxapp-union.com/forum.php?mod=viewthread&tid=2484
Save the following code as a PHP file and run it in the root directory of the site.
if (Isset ($_get[' dir ')) {//config the Basedir
$basedir =$_get[' dir '];
}else{
$basedir = '. ';
}
$auto = 1;
Checkdir ($basedir);
function Checkdir ($basedir) {
if ($dh = Opendir ($basedir)) {
while (($file = Readdir ($DH))!== false) {
if ($file! = '. ' && $file! = ' ... ') {
if (!is_dir ($basedir. " /". $file)) {
echo "filename
$basedir/$file ". Checkbom (" $basedir/$file ")." <br> ";
}else{
$dirname = $basedir. " /". $file;
Checkdir ($dirname);
}
}
}
Closedir ($DH);
}
}
function Checkbom ($filename) {
Global $auto;
$contents = file_get_contents ($filename);
$charset [1] = substr ($contents, 0, 1);
$charset [2] = substr ($contents, 1, 1);
$charset [3] = substr ($contents, 2, 1);
if (Ord ($charset [1]) = = 239 && ord ($charset [2]) = = 187 && ord ($charset [3]) = = 191) {
if ($auto = = 1) {
$rest = substr ($contents, 3);
Rewrite ($filename, $rest);
Return ("<font Color=red>bom found, automatically removed.</font>");
} else {
Return ("<font Color=red>bom found.</font>");
}
}
else return ("BOM not Found.");
}
function rewrite ($filename, $data) {
$filenum = fopen ($filename, "w");
Flock ($filenum, LOCK_EX);
Fwrite ($filenum, $data);
Fclose ($filenum);
}
Now it seems that the problem is small, but the solution is not a big problem, usually still more look at the official forum, the community.
Small program for Android rendering problem