通过这个AJAX调用得到的mch_desc是乱码,被调用的页面时getmach.php,请教一下这是哪里出现的问题啊,谢谢大家function callServer()
{
var mch = document.getElementById("mch").value;
var url = "getmch.php?mch=" + mch;
xmlHttp.open('GET',url,true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage()
{
if (xmlHttp.readyState == 4)
{
var response = xmlHttp.responseText;
document.getElementById("mch_desc").value=response;
}
}getmach.php<?php
require("../global_manage.php");if ($_GET)
{
$mac=$_GET['mch'];
}
$sql="select mac_desc from mac_mstr where mac_code = '".$mac."'";
$res = $DB->fetch_one_array($sql);
$mac_desc=$res['mac_desc'];
echo $mac_desc;
?>
{
var mch = document.getElementById("mch").value;
var url = "getmch.php?mch=" + mch;
xmlHttp.open('GET',url,true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage()
{
if (xmlHttp.readyState == 4)
{
var response = xmlHttp.responseText;
document.getElementById("mch_desc").value=response;
}
}getmach.php<?php
require("../global_manage.php");if ($_GET)
{
$mac=$_GET['mch'];
}
$sql="select mac_desc from mac_mstr where mac_code = '".$mac."'";
$res = $DB->fetch_one_array($sql);
$mac_desc=$res['mac_desc'];
echo $mac_desc;
?>
加上一句
header("Content-type:text/html;charset=gbk");
type: "POST",
url: "url.php",
data: "txt="+$('#tbox1').val(),
success: function(msg){
$("#Response").text(msg);
},
contentType:"application/x-www-form-urlencoded;charset=utf-8"
});