Hi
sorry for the mistake
Actualy i found that the code is not working even if i send a string
the actual code  is as follows

Views.py


return HttpResponse('Hello')

Javascript

var ajaxRequest;
  try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
     } catch (e){
       // Internet Explorer Browsers
  try{
        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
  try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (e){
// Something went wrong
         alert("Your browser broke!");
         return false;
        }
    }
    }
alert("Here");
 ajaxRequest.onreadystatechange = function(data){
 alert("ajax");
 if(ajaxRequest.readyState == 4){
     alert(data.responseText);
    }
 alert("out");
var infoToSend = encodeURI("?
state_id="+id+"&company_id="+document.getElementById('Hidden_Capital1'));
 ajaxRequest.open("GET", "http://localhost:8000/Software/update_state/";, true);
 ajaxRequest.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
 ajaxRequest.setRequestHeader("Content-length", infoToSend.length);
 ajaxRequest.setRequestHeader("Connection", "close");
 ajaxRequest.send(infoToSend);

On Sun, Aug 1, 2010 at 5:03 PM, Daniel Roseman <[email protected]> wrote:
> On Aug 1, 8:54 am, Himanshu Srivastava <[email protected]>
> wrote:
>> Hi
>> I am sending  a Json data from django on an ajax call as A
>> HttpResponse but i get it as undefined when i try to access it in
>> javascript
>> The code is as follows\
>>
>> Views.py
>>
>> data=simplejson.dump(dic)
>> return HttpResponse(data,mimetype='application/json')
>>
>> Javascript
>>
>> var ajaxRequest;
>>    try{
>>          // Opera 8.0+, Firefox, Safari
>>          ajaxRequest = new XMLHttpRequest();
>>       } catch (e){
>>         // Internet Explorer Browsers
>>    try{
>>          ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
>>       } catch (e) {
>>    try{
>>          ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
>>       } catch (e){
>> // Something went wrong
>>           alert("Your browser broke!");
>>           return false;
>>          }
>>      }
>>      }
>> alert("Here");
>>  ajaxRequest.onreadystatechange = function(data){
>>  alert("ajax");
>>  if(ajaxRequest.readyState == 4){
>>       document.getElementById('State_Over').innerHTML=res.state_name;
>>       document.getElementById('Farming_Rate').innerHTML=res.Farming_Rate;
>>
>>      }
>>  alert("out");
>> var infoToSend = encodeURI("?
>> state_id="+id+"&company_id="+document.getElementById('Hidden_Capital1'));
>>  ajaxRequest.open("GET", "http://localhost:8000/Software/update_state/";, 
>> true);
>>  ajaxRequest.setRequestHeader("Content-type",
>> "application/x-www-form-urlencoded");
>>  ajaxRequest.setRequestHeader("Content-length", infoToSend.length);
>>  ajaxRequest.setRequestHeader("Connection", "close");
>>  ajaxRequest.send(infoToSend);
>>
>> PLEASE HELP SOON...
>> BYE
>
> Well, this obviously isn't the code that gives that error, as you
> haven't used `responseText` anywhere. You have used `res`, without
> defining it, in your onreadystatechange handler.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to