Actually, what's the problem: I do a live search by mass media. For the basis I took the code from the example http://ajaxs.ru/lesson/ajax/132-zhivoj_poisk.html:
<script type="text/javascript"> $(function() { $("#search").keyup(function(){ var search = $("#search").val(); $.ajax({ type: "POST", url: "http://сайт/search.php", data: {"search": search}, cache: false, success: function(response){ $("#resSearch").html(response); } }); return false; }); }); </script>
At first I checked the usual search form, everything works, but when I use this script, I get the hieroglyphs in the $ search variable, for example, the word "search" looks like this: " РїРѕРёСЃРє " the file index, the search, and the file with the array are encoded with wine-1251 , in each file, the beginning is written
header("Content-type: text/html; charset=windows-1251");
Here is the code for the search itself: header ("Content-type: text / html; charset = windows-1251");
include_once 'array.php'; if(isset($_POST[search])){ $search = $_POST['search']; $search = addslashes($search); $search = htmlspecialchars($search); $search = stripslashes($search); echo $search; foreach ( $name as $key => $value ) { foreach ( $value as $ke => $valu ) { foreach ( $valu as $k => $val ) { $l=''; $l=strlen($search); $str = substr($val,0,$l); if ($str==$search){ echo "<a href=\"/names/$ke.html\">$val</a><br>"; } } } } }
How to solve this problem? Namely, the correct transmission of the request!