【发布时间】:2011-07-15 16:35:08
【问题描述】:
我的问题与
中提到的类似use of ajax in django problem with the code
我尝试了给出的解决方案,但我仍然没有得到响应值。下面是我的代码
chkAjax.html
------------
<html>
<head>
<script>
function chkAjax(form)
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
document.getElementById("t1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/sign?text="+form.text1.value,true);
xmlhttp.send();
}
function DoNav(theUrl,form)
{
theUrl = theUrl + '?text=' + form.text1.value;
document.location.href = theUrl;
}
</script>
</head>
<body>
<form method="get" action="">
<input type="text" name="text1" id="t1" onkeyup = 'chkAjax(this.form)'/>
</form>
</body>
</html>
下面是我的处理程序的代码
from django.http import HttpResponse
c=self.request.get('text')
c=c + "b"
self.response.write("hi")
使用 alert() 我知道我收到了响应但值为空,所以请帮我解决这个问题
【问题讨论】:
-
大家好,我已经解决了这个问题,所以不需要回复所有人
-
关闭问题或找到最佳答案 ;)
-
如何关闭队列??我不知道
标签: javascript python ajax django google-app-engine