jQuery HTTP post request

jQuery HTTP post request

Hi!

 

As I am new to jQuery i have to ask for the .post function!

I was using before the XMLHttpRequest object. But with this I got problems with special characters in the received XML. Changeing the encoding didn't help so far...

 

This I want to do:

Post an http request with an XML document and receive an XML response.

 

  1. // Send the xHTTPRequest to the server in the browser adress
    function httprequest(xmlReqList)
    {
     // Überprüfen ob XMLHttpRequest-Klasse vorhanden und erzeugen von Objekte für IE7, Firefox, etc.
     if (typeof XMLHttpRequest != 'undefined')
     {
         xhttp = new XMLHttpRequest();
     }
     
     // Wenn im oberen Block noch kein Objekt erzeugt, dann versuche XMLHTTP-Objekt zu erzeugen
     // Notwendig für IE6 oder IE5
     if (!xhttp)
     {
      try
      {
       xhttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
       try
       {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
       }
       catch(e)
       {
        xhttp = null;
       }
      }
     }



























  2.  if (xhttp)
     {
      xhttp.onreadystatechange = doHttpReadyStateChange;
      xhttp.open("POST","/cgi-bin/ILRReadValues.exe",true);
      xhttp.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
      xhttp.responseType = 'Document';
      xhttp.send(xmlReqList); 
     }
     */
    }








  3. // Only need for old IExplorer Get Event new data
    function doHttpReadyStateChange()
    {
     if (xhttp.readyState == 4)
     {
      GetDataFromResponse(this);
     }
    }






 

The var xmlReqList is a XML DOM object:

  1.       var parser=new DOMParser();
          var doc=parser.parseFromString(text,'text/xml');

If I try it with jQuery like this:

  1.   var xmlstring = xmlReqList.xml;  
      $.post('/cgi-bin/ILRReadValues.exe' + xmlstring, { }, callback); 
  2. function callback(content){ 
        /* do stuff with data.... */
    }

The response content is: 'Done.\r\n' and not the received XML??

Or do I handle wrong the .post function? How to pass directly the XML DOM object?