The Magical%EF%BB%BF

Source: Internet
Author: User
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 $.ajax of the input box ({ty PE: "Get",//ajax submit as Get submit URL: "__app__/index/get_search_showdiv",//URL address of processing page data: "S_name=" +encodeuricomponent ($ (' #select_paramName '). Val ()),//The parameter to be passed success:function (data) {//succeeded after executing the method if (Data! = "") {var ss;ss = Data.spl   It ("@"); The split returns the string var Layer;layer = "
 
  < td="">";} Layer + = "
 
 
 
  
  "; Create a tablefor (Var i=0;i
 
 
"; $ (' #searchresult '). empty (); First empty all child elements under #searchresult $ (' #searchresult '). append (layer);//Insert the table you just created into #searchresult $ ("#searchresult"). css ("Display", ""); $ ('. Line '). Hover (function () {///listen for the mouse hover event of the cue box $ (this). addclass ("hover");},function () {$ (this). Removeclass ("hover");}); $ ('. Line '). Click (function () {///listen for the 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 automatically prompts   $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?


Reply to discussion (solution)

%EF%BB%BF is not the URL code of the BOM header?
Because there is only one, so your program loads only one of the files that has a BOM header

Public Function Get_search_showdiv ()
The php script file where this function is located has a BOM

%EF%BB%BF is not the URL code of the BOM header?
Because there is only one, so your program loads only one of the files that has a BOM header



Sorry, these days travel, just come back, what mean, didn't see understand.

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 received a string of shapes like xxx@xxx@xxx@.
The BOM is, of course, attached to the front of the content: bomxxx@xxx@xxx@
After splitting into an array, it is natural that only the first item has a BOM.

So how do we solve this problem?

  • 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.