ajax传递参数给php,php接收不到

2024-11-02 00:23:33
推荐回答(2个)
回答1:

$.aiax 你这里就写错了 是$.ajax

url:'CH_EN.php&cste='+language,这里又错
url:'CH_EN.php?cste='+language,

$('#language').blur(function(){
var language = $(this).val();
alert(language);
$.ajax({
type:'get',
url:'CH_EN.php?cste='+language,
success:function(rep){
alert(rep.status);
}
})
})
});

CH_EN.php
header("Content-type: text/json; charset=utf-8");
$cste = isset($_GET['cste']) ? $_GET['cste'] : 'CH';
echo json_encode(array('code'=>$cste,'status'=>'y'));
?>

回答2:

url:'CH_EN.php&cste='+language,

这儿该是 ? 吧


url:'CH_EN.php?cste='+language,