function imageHandler(myToDo,myimageId)
{ 
    $.get('{{path('imageHandler')}}',
        {imageId: myimageId, toDo: myToDo},  
        function(response) {
            if(response.code == 100 && response.success) {
                //success
                alert(myToDo+' was sent');
            }
            else if(response.code == 200) {
                //code 200 = user not logged in
            }; 
        }, "json");
}
This is the working ajax code for a symfony2 application im writing.
I'm using $.get from jquery to send the data, how is it possible to write this function without jQuery?, I have already looked into other similar questions but I don't understand the answers.
Already tried this
function imageHandler(myToDo,myimageId)
{ 
    var hr = new XMLHttpRequest(); 
    var vars = {imageId: myimageId, toDo: myToDo};
    hr.open("GET", "{{path('imageHandler')}}", true); 
    hr.setRequestHeader("Content-type", "application/json"); 
    hr.onreadystatechange = function() 
    {
      if(hr.code == 100 && hr.success)
      {
        //success
      }
       else if(hr.code == 200) 
       {
        //code 200 = user not logged in
       }
    } 
    hr.send(vars);  
}
here is the answer:
A co-worker just answered the question. Thanks for your help, here is the answer
function imageHandler(myToDo,myimageId)
{ 
    var xml = new XMLHttpRequest();  
    xml.open("GET", "{{path('imageHandler')}}", true); 
    xml.setRequestHeader("Content-type", "application/json"); 
    xml.onreadystatechange = function() 
    {
       var serverResponse = JSON.parse(xml.responseText);
       if(serverResponse.code == 100 && serverResponse.success)
       {
        //success 
       }
       else if(serverResponse.code == 200) 
       {
          //not logged in
       }
        xml.send({imageId: myimageId, toDo: myToDo});   
   }
}
 
     
     
    