注册 登录
编程论坛 ASP.NET技术论坛

ajax局部刷新取值问题

yunj1105 发布于 2007-09-07 08:28, 1903 次点击

用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);
}
} }红色的取不到值

11 回复
#2
yunj11052007-09-08 11:44
大家来看看啊
#3
jyoseyi2007-09-08 19:52
页面加载的 时候取上传文件的 名字
#4
jyoseyi2007-09-08 19:55
那个时候
Request["td"] == null

没有进去是把,取不到文件的名字
#5
风雨中2007-09-09 11:26
把出现在问题发出来看看啊.
#6
yms1232007-09-09 12:19

Ajax个人所知目前对上传的操作不管用,还是只能用传统办法。

#7
yunj11052007-09-10 09:29
没有错误提示 只是这段代码没作用
这个就是要实现上传控件里的地址给了图片和Text1 不是要实现上传
#8
梦灵儿2007-09-10 19:38

恩.AJAX学的不够好.恩这句话也是刷新的.

刷新自动刷新代码<meta http-equiv="refresh" content="1;url=刷新自动刷新代码.htm">-->

#9
师妃暄2007-09-11 15:37
xmlhttp.Open("POST","zstd.aspx?td=zstd",true);

POST改成GET
#10
yunj11052007-09-12 08:02
好 我去试试
#11
skyland842007-09-12 23:30
脑袋有坑~!AJAX 明摆着告诉你 不需要刷新页面~1也就是不会 调用页面的LOAD 事件~!

而AJAX 能不能上传 文件我还没有处理过不晓得!



#12
yunj11052007-09-14 10:20
不要乱讲话 你先看看会不会调用页面的LOAD 事件再说
1