×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    16

    XMLHttpRequest.status is always 0

    Hi,

    I'm having a problem where by XMLHttpRequest.status is always 0 and never correctly retrieves data.

    This below example to work in a web browser when not using any additional WRT files. However, when I try this inside a WRT app, this fails, due to XMLHttpRequest.status = 0.


    Thanks!

    var request;
    function init(){

    document.getElementById('p').innerHTML="Initializing";

    request = new XMLHttpRequest();
    request.open("GET", "http://www.macrumors.com", false);
    request.send(null);


    request.onreadystatechange = function() {
    if(request.readyState == 4) {
    if (request.status == 200) {
    var response = request.responseText;

    alert(response);
    }
    else {
    alert ( request.status );
    }
    }

    }
    }

    Here's my plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/DTDs/plist-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>DisplayName</key>
    <string>test</string>
    <key>Identifier</key>
    <string>com.test.basic.widget</string>
    <key>Version</key>
    <string>1.0</string>
    <key>AllowNetworkAccess</key>
    <true/>
    <key>MainHTML</key>
    <string>index.html</string>
    <key>MiniViewEnabled</key>
    <false/>
    </dict>
    </plist>

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: XMLHttpRequest.status is always 0

    I don't see anything wrong in there really, anyway, I wiki would have rather many working examples: http://wiki.forum.nokia.com/index.ph...th_WRT_widgets, so maybe you could see what would be different in your case.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    178

    Re: XMLHttpRequest.status is always 0

    Couple of things...

    Code:
    request.open("GET", "http://www.macrumors.com", false);
    Isn't that false suppose to be true, if you are using it asynchronously?

    And set the callback, before calling send().
    Code:
    request.onreadystatechange = onSent;

Similar Threads

  1. XMLHttpRequest status OK but XML doc empty
    By nbanke in forum Symbian
    Replies: 4
    Last Post: 2010-07-17, 08:53
  2. XMLHTTPREQUEST
    By yynneejj in forum Symbian
    Replies: 7
    Last Post: 2010-06-08, 14:55
  3. Replies: 1
    Last Post: 2010-01-20, 15:00
  4. XMLHttpRequest problem
    By kogan_y in forum Symbian
    Replies: 3
    Last Post: 2009-12-18, 02:46
  5. XMLHttpRequest status always returns NULL
    By vinothg in forum Symbian
    Replies: 6
    Last Post: 2009-09-22, 09:22

Posting Permissions

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