Results 1 to 2 of 2

Thread: ajax data were in xml,how in php parse/process them like prior

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default ajax data were in xml,how in php parse/process them like prior

    I know how to get
    registerRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    DATA from a request and enter them in database or response(echo) via ajax/php, well what if that ajax data were in xml (Basic) format, how in php parse/process them like prior?
    give URLs...

    Code:
    function registerUser() {
      t = setInterval("scrollImages()", 50);
      document.getElementById("register").value = "Processing...";
      registerRequest = createRequest();
      if (registerRequest == null) {
        alert("Unable to create request.");
      } else {
        var url = "register-feedback.php";
        var requestData = "username=" + 
          escape(document.getElementById("username").value) + "&password=" +
          escape(document.getElementById("password1").value) + "&firstname=" +
          escape(document.getElementById("firstname").value) + "&lastname=" +
          escape(document.getElementById("lastname").value) + "&email=" +
          escape(document.getElementById("email").value) + "&genre=" +
          escape(document.getElementById("genre").value) + "&favorite=" +
          escape(document.getElementById("favorite").value) + "&tastes=" +
          escape(document.getElementById("tastes").value);
        registerRequest.onreadystatechange = registrationProcessed;
        registerRequest.open("POST", url, true);
        registerRequest.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
        registerRequest.send(requestData);
      }
    }
    
    function registrationProcessed() {
      if (registerRequest.readyState == 4) {
        if (registerRequest.status == 200) {
          document.getElementById('wrapper').innerHTML =
            registerRequest.responseText;
        }
      }
    }

  2. #2
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    use
    var doc = xhr.responseXML;
    and parse xml dom tree?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •