The Magic%EF%BB%BF Solution

Source: Internet
Author: User
The Magical%EF%BB%BF
Don't say much nonsense about the code:
Front desk:

function On_post_form () {
var f = document.post_myform;
var s_paramname = document.getElementById ("Select_paramname"). Value;
F.action = "__app__/index/select_infomessage-s_paramname-" +encodeuricomponent (s_paramname) + ". html";
F.submit ();
}




$ (document). Ready (function () {
$ (' #select_paramName '). KeyUp () The ID of the function () {//Input box is search, which listens for the KeyUp event of the input box
$.ajax ({
Type: "Get",//ajax commit as Get commit
URL: "__app__/index/get_search_showdiv",//URL address of the processing page
Data: "S_name=" +encodeuricomponent ($ (' #select_paramName '). Val ()),//parameters to pass
Success:function (data) {//Successful post-execution method
if (Data! = "") {
var SS;
SS = Data.split ("@"); Split the returned string
var layer;
Layer = "
<>


"; Create a tablefor (var i=0;i layer + = " ";} Layer + = "
"+ss[i]+"
";
$ (' #searchresult '). empty (); Empty all child elements under #searchresult first
$ (' #searchresult '). append (layer);//Insert the table you just created into #searchresult
$ ("#searchresult"). CSS ("Display", "");
$ ('. Line '). Hover (function () {///listen to the mouse hover event of the cue box
$ (this). addclass ("hover");
},function () {
$ (this). Removeclass ("hover");
});
$ ('. Line '). Click (function () {////Listen for a prompt for mouse clicks event
$ (' #select_paramName '). Val ($ (this). text ());
$ ("#searchresult"). CSS ("display", "none");
Changecoords ();
});
}else{
$ (' #searchresult '). empty ();
}
}
});
});
});


Background:

Public Function Get_search_showdiv ()
{
UrlEncode urldecode text box auto prompt
$keyword = UrlDecode ($_get[' s_name ');
$condition = "F_hotname like '%". $keyword. " %'";
$info = $this->model->table (' Forest ')->field (' F_hotname ')->where ($condition)->order (' f_id desc ')- >limit (5)->select ();
if ($keyword! = "") {
foreach ($info as $vo)
{
echo $vo [' F_hotname ']. ' @';

}else{

echo "";
}
}


Problem symptoms: For example, enter "Baidu"
Shown in the DIV #searchresult:
Baidu Antivirus
Baidu Guardian
Baidu Video

If you choose the first Baidu anti-virus, Firefox browser display:
http://192.168.1.101/index/select_infomessage-s_paramName-%EF%BB%BF% Baidu Antivirus. html
There's nothing ...
If you choose the second Baidu Guardian, Firefox browser display:
http://192.168.1.101/index/select_infomessage-s_paramname-Baidu Guardian. html
Normal search, you can search for information. Other items are normal, except the first one is not normal.

Degree Niang said is BOM head, I all pages are to BOM head, coding is UTF8, try a lot also can not solve the problem.
Why do you add%ef%bb%bf% at the first time,,,,, and all other items can be displayed normally?

------Solution--------------------
Public Function Get_search_showdiv ()
The php script file where this function is located has a BOM
------Solution--------------------
The hexadecimal representation of the BOM header for the Utf-8 file is EFBBBF
URL encoding is%EF%BB%BF

The URL for the AJAX request is __app__/index/get_search_showdiv
Obviously this is in the use of frames

The framework will load at least 3 files when processing a request
So any file that is loaded has a BOM header, and the returned content will have a BOM header

The connection becomes ....%EF%BB%BF Baidu anti-virus. html
Instead of ....%EF%BB%BF%EF%BB%BF Baidu anti-virus. html
It means that only one file has a BOM header.

Ajax receives a string that is shaped like [email protected] @xxx @
The BOM is, of course, attached to the front of the content: [email protected] @xxx @
After splitting into an array, it is natural that only the first item has a BOM.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.