Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross-Site XmlHttpRequest returns to computer but not to XmlHttpRequest object.

    I am doing a cross-site XmlHttpRequest and using Wireshark i can see the packet return with the XML data in it, but my XmlHttpRequest object gets a status code of 0 and has no responseText. (I am using Firefox 3.5 which should support cross-site requests).

    on load i call

    function init()
    {
    //Create XmlHtmlRequest object
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = processResults;
    }

    function performSearch()
    try
    {
    xmlhttp.open("GET", http://server:8080/search?text=help, true);
    xmlhttp.withCredentials = "true";
    xmlhttp.send(null);
    }
    catch (e)
    {
    alert("Can't connext to server:\n" + e.toString() );
    }
    }

    function processResults()
    {
    if (xmlhttp.readyState == 4)
    {
    alert("AllResponseHeaders: " + xmlhttp.getAllResponseHeaders() );
    if xmlhttp.status == 200)
    {
    document.getElementById('divReuslts').innerHTML = xmlhttp.responseText;
    }
    else
    {
    alert("Error! Status" + xmlhttp.status + " - " + xmlhttp.statusText);
    }
    }
    }


    I get the following error response header:

    Can't connext to server:
    [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://server:8080/project/pages/search_page.seam :: performSearch :: line 132" data: no]


    Any ideas why i can see the data in Wireshark but my object doesn't receive it?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Please use code tags!

    You really should set the onreadystatechange after the open statement.

    Code:
                 xmlhttp.open('GET', "http://server:8080/search?text=help", true);  
                 xmlhttp.withCredentials = "true";  
                 xmlhttp.onreadystatechange = processResults;  
                 xmlhttp.send();
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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