用ajax实现局部刷新,只是将图片地址选好了,然后将图片和地址显示出来,可是有错误大家帮忙看看
HTML
<img src="" style="width: 79px; height: 68px" id=img_td />
<input id="Text1" type="text" />//地址显示
<input id="FileUpLoad" type="file" runat="server"/>
<input id="Button1" type="button" value="上传" onclick="getData()"/>
<script language="javascript">
var xmlhttp;
var id;
function getData()
{
xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
xmlhttp.onreadystatechange=StateChange;
xmlhttp.Open("POST","zstd.aspx?td=zstd",true);
xmlhttp.Send();
}
function StateChange()
{
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
FillData(xmlhttp.responseText);
}
}
}
function FillData(strcity)
{
document.getElementById("Text1").innerText=strcity;
document.getElementById("img_td").src=strcity;
}</script>
zstd.aspx页面
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request["td"] != null)
{
string strFileFullName = System.IO.Path.GetFileName(this.FileUpLoad.PostedFile.FileName);
string path = "../upfiles/" + strFileFullName;
Response.Clear();
Response.Write(path);
}
} }红色的取不到值
ajax局部刷新取值问题