Wrox Programmer Forums
|
RSS and Atom Ask questions, get answers, discuss creating RSS and Atom feeds or programming apps or sites that create or consume RSS/Atom. Please leave any RSS/Atom politics out of this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the RSS and Atom section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2005, 12:37 PM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default xmlhttp

function testXMLHTTP(){
    var docXML = loadXMLDoc("dummy.xml", false);
    postXMLDoc(docXML, "./echo.php", true);//"ciao"
}

///////////////// xmlhttp section ///////////////////
function initReq(){
    if (window.req){
        req.abort();
    }
    //delete req;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();

  // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
          //"Msxml2.XMLHTTP.4.0"
          //"Microsoft.XMLHTTP"
      req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
  }
 }


function postXMLDoc(doc, url, async){
    //initReq();
    //async = true;
    if (async){
      req.onreadystatechange = postReqChange;
  }
  req.open("POST", url, async);
  req.setRequestHeader('content-type', 'text/xml');
  req.send(doc);
  if (!async){
      alert("mandato: "+req.responseText);
  }
  else{
      alert("aspetta");
  }
}

function postReqChange() {
  // only if req shows "loaded"
  if (req.readyState == 4) {
    // only if "OK"
    if (req.status == 200) {
      alert(req.responseText);
    } else {
            alert("There was a problem retrieving the XML data:\n" +req.statusText);
    }
  }
}


///////////php script//////////////// (echo.php)

<?php
            $sXML = $GLOBALS['HTTP_RAW_POST_DATA'];

      echo "$sXML";

      // Open a text file and erase the contents if any
      $fp = fopen("posted.xml", "w");

      // Write the data to the file
      fwrite($fp, $sXML);

      // Close the file
      fclose($fp);


      //$headers = getallheaders();
      /*foreach ($headers as $name => $content) {
      echo "$name = $content<br>n";
      }*/
      //echo "{$headers["my-header"]}";
    ?>


//////////////////////xml document////////////////////// (dummy.xml)

<progetto id="0"><schema id="schF0" tipo="schemaFunzionale"><schemaFunzionale/><oggetto id="imm0" tipo="immagine" x="50" y="50"><immagine nomeFile="cacca.jpg"/><etichettaAssociata id="etich0"/></oggetto><oggetto id="etich0" tipo="etichetta" x="100" y="100"><etichetta idOggettoEtichettato="imm0">commento cacca</etichetta></oggetto></schema></progetto>







Similar Threads
Thread Thread Starter Forum Replies Last Post
xmlhttp help ojaynet RSS and Atom 2 April 8th, 2005 04:13 PM
XMLHTTP ffbalota Classic ASP XML 7 October 7th, 2003 05:11 PM
XMLHTTP ffbalota ASP.NET 1.0 and 1.1 Professional 1 August 16th, 2003 01:29 PM
XMLHTTP ffbalota Classic ASP Professional 0 June 25th, 2003 02:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.