Magic % EF % BB % BF

Source: Internet
Author: User
The Magic % EF % BB % BF does not talk much about the code:
Front-end:
function on_post_form(){var f = document.post_myform;var s_paramName = document.getElementById("select_paramName").value;        f.action = "/index.php/index/select_infomessage-s_paramName-"+encodeURIComponent(s_paramName)+".html";        f.submit();}


$ (Document ). ready (function () {$ ('# select_paramName '). keyup (function () {// The id of the input box is search. here, the keyup event of the input box is monitored $. ajax ({type: "GET", // The AJAX submit method is GET submit url: "/index. php/index/get_search_showp ", // The URL data of the processing page:" s_Name = "+ encodeURIComponent ($ ('# select_paramName '). val (), // The parameter success to be passed: function (data) {// if (data! = "") {Var ss; ss = data. split ("@"); // splits the returned string var layer; layer ="
 
  
";} Layer + ="
 
 
 
  
  
"; // Create a tablefor (var I = 0; I
 
 
"; $ ('# Searchresult '). empty (); // first clear # All child elements under searchresult $ ('# searchresult '). append (layer); // Insert the created table to # searchresult $ ("# searchresult" ).css ("display", ""); $ ('. line '). hover (function () {// listens to the mouse hover event in the prompt box $ (this ). addClass ("hover") ;}, function () {$ (this ). removeClass ("hover") ;}; $ ('. line '). click (function () {// click event $ ('# select_paramname') in the listener prompt box '). val ($ (this ). text (); $ ("# searchresult" ).css ("display", "none"); ChangeCoords () ;});} else {$ ('# searchresult '). empty ();}}});});});


Background:
Public function get_search_showp () {// The 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 "";}}


Symptoms: for example, enter "Baidu"
In p # searchresult, the following information is displayed:
Baidu anti-virus
Baidu Guardian
Baidu audio and video

If you select the first Baidu anti-virus item, the Firefox browser displays the following:
Http: // 192.168.1.101/index/select_infomessage-s_paramname-effecef?bb=bf=baidu.html
Nothing...
If the second Baidu guard option is selected, the Firefox browser displays the following:
Http: // 192.168.1.101/index/select_infomessage-s_paramname-baidu Weishi .html
You can search for information normally. Other items are normal, but the first item is not normal.

Du Niang said that it is the bom header. all my pages go to the bom header, and the code is also utf8. if I try a lot, it will not solve the problem.
Why will % EF % BB % BF %, and be added in the first item be displayed normally in other items.


Reply to discussion (solution)

% EF % BB % BF is not the url encoding of the BOM header?
Because there is only one file, there is only one BOM header in the file loaded by your program.

Public function get_search_showp ()
The php script file where this function is located contains BOM.

% EF % BB % BF is not the url encoding of the BOM header?
Because there is only one file, there is only one BOM header in the file loaded by your program.



Sorry, I was on a business trip over the past few days. I just came back and didn't understand what it meant.

The hexadecimal format of the BOM header of the UTF-8 file is EFBBBF.
The url is encoded as % EF % BB % BF.

The url of the ajax request is/index. php/index/get_search_showp.
Obviously, this is the framework

When processing a request, the framework loads at least three files.
Therefore, if any file to be loaded has a BOM header, the returned content will have a BOM header.

The connection is changed to ...20.ef1_bb1_bf .html.
Instead of ...w.efw.bbw.bfw.efw.bbw.bfbaidu.html
Indicates that only one file has a BOM header.

Ajax receives a string like xxx @.
Of course, BOM is appended to the content: BOMxxx @ xxx @
After being split into arrays, the first item is BOM.

How can this problem be solved?

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.