CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: AJAX question/issue

  1. #1
    Join Date
    Feb 2011

    AJAX question/issue

    I am new to AJAX and am trying to write my first AJAX program. I am trying to reach out and connect with a server. I "should" be getting some XML data sent back to me but my responseXML remains null. Below is the code I am using and I will also print out what I am hoping to get back. I am able to create the XMLHttpRequest and my readyState does reach 4. My status is 0 but I expected that.

    The code (and I have included some document.writes just to help me debug) is:
    <script type="text/javascript">
    function loadXMLDoc()
    document.write(" In function");
    var xmlhttp;
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      document.write(" created request ");
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      if (xmlhttp.readyState==4)
    <button type="button" onclick="loadXMLDoc()">Request data</button>
    When I put the "http://localhost:8080/vlrestapi/v1.0/system" into a browser, this is what I get back and what I hope to pull back with my AJAX program but it is not happening:

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <VLResponse>
      <content class="string">VisuaLinks REST API | Host: nb-lhunt/ | Time: Wed Feb 09 14:38:56 EST 2011</content> 
    Any help anyone could give me would be greatly appreciated.

    Thank you
    Last edited by PeejAvery; February 9th, 2011 at 09:30 PM. Reason: Added code tags

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: AJAX question/issue

    Make sure the status returns 200 before grabbing the responseText or responseXML.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)