我開始與Jquery,所以我想做的事情很簡單:從輸入標籤中獲取一個字符串,並將其放入一個div標籤。jQuery的ajax發送字符串到PHP和特殊的字符,如#
我Jquery的代碼:
$(document).ready(function(){
$("#recherche").keyup(function(){
var recherche = $(this).val();
var data = 'motclef=' + recherche;
$.ajax({
type : "GET",
url : "result.php",
data : data,
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
success: function(server_response){
$("#resultat").html(server_response).show();
}
});
});
});
我的PHP代碼:
<?php
if(isset($_GET['motclef'])){
$motclef = $_GET['motclef'];
echo $motclef;
}
?>
它正常工作,甚至caracters如EAC ...甚至中國caracters,但它不是以#或&工作。我怎樣才能使它工作? 非常感謝。
嘗試改變的contentType或刪除其 – Sam
我都試過,但結果相同 – user1836529