dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to see passing data in the log of XMLHttpRequest

  1. #1
    Join Date
    Mar 2014
    Posts
    8

    how to see passing data in the log of XMLHttpRequest

    I am trying to using XMLHttpRequest to send request from my server to browser. Now everything works, and the access_log on my server shows:

    ::1 - - [13/Mar/2014:18:21:55 -0700] "GET /CDCollection.html HTTP/1.1" 304 -
    ::1 - - [13/Mar/2014:18:21:55 -0700] "GET /CDCollection.html HTTP/1.1" 304 - "http://localhost:8888/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36"
    ::1 - - [13/Mar/2014:18:21:57 -0700] "POST /cd_catalog.xml HTTP/1.1" 200 4122
    ::1 - - [13/Mar/2014:18:21:57 -0700] "POST /cd_catalog.xml HTTP/1.1" 200 4122 "http://localhost:8888/CDCollection.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36"



    Now I want to see how these code and server passing data. For example: there are some data in cd_catalog.xml, and I want to see the actual data in these .xml in my server log, to see how they are passed. (eg. I want to see 'server is receiving <TITLE>Picture book</TITLE>....' or something like this)

    I searched something online, but I cannot find the solution. My code is (it's sample code from online tutorial

    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function loadXMLDoc()
    {
    var xmlhttp;
    var txt,x,i;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    xmlDoc=xmlhttp.responseXML;
    txt="";
    x=xmlDoc.getElementsByTagName("ARTIST");
    for (i=0;i<x.length;i++)
    {
    txt=txt + x[i].childNodes[0].nodeValue + "<br>";
    }
    document.getElementById("myDiv").innerHTML=txt;
    }
    }



    xmlhttp.open("POST","cd_catalog.xml",true);
    //alert('hello');
    xmlhttp.send();
    }
    </script>
    </head>

    <body>

    <h2>My CD Collection:</h2>
    <div id="myDiv"></div>
    <button type="button" onclick="loadXMLDoc()">Get my CD collection</button>

    </body>
    </html>

  2. #2
    Join Date
    Mar 2014
    Posts
    8
    Just be clear, I need to see each data passing in the server log.

  3. #3
    Join Date
    Mar 2011
    Posts
    1,158
    It isn't clear what you want to see in the server log.

    If you want to see the details of the AJAX request, you can change it from "POST" to "GET" and then the data will appear in the query string.

    There's no good way to save the data returned by the server in the log. You could create a script that would save that information in a different file, but you don't want to put it in the server log file.

  4. #4
    Join Date
    Mar 2014
    Posts
    40
    Check the console of your broswer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles