2011-03-15 28 views
0

我的問題是類似於提到在如何在django應用程序中實現ajax?

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") 

使用警報()我才知道,我得到了響應,但與空值,請幫助我進入這個

+0

大家好,我得到了解決這個問題,所以沒有必要回答所有 – mahesh 2011-03-15 10:43:36

+2

關閉問題或找到最佳答案;) – Efazati 2011-03-15 10:48:40

+0

如何關閉que?我不知道 – mahesh 2011-03-18 08:43:37

回答

相關問題