×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    34

    POST method of XMLHttpRequest not working on phone

    Hello everybody,
    When i use GET method of xmlhttprequest, I don't have a problem, i get the results from the server.
    On the other hand when i use POST method, it doesn't work on the phone (E6), but it works on web app simulator! Why could this happen? Is there another method that i should use?

    Code:
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", server_addr, false);
    xmlhttp.send(some string here);
    xmlhttp.responseText returns empty string
    xmlhttp.responseXML returns null

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    34

    Re: POST method of XMLHttpRequest not working on phone

    I have solved the problem, for helping the newbie widget developers like me, let me write the solution.
    just add header to your request before sending it.
    in my case which is the following

    Code:
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("POST", server_addr, false);
    xmlhttp.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
    xmlhttp.send(some string here);

  3. #3
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: POST method of XMLHttpRequest not working on phone

    Hi,

    Thank you for sharing the solution with the community.

    In addition to that header I would suggest to add following headers as well and use asynchronous method instead of synchronous .open("POST", url, true). Then you need to introduce onreadystatechange callback, but it is simple to do.
    Code:
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    Br,
    Ilkka

Similar Threads

  1. xmlhttprequest timeout method?
    By loellanthony in forum [Archived] Qt Quick
    Replies: 4
    Last Post: 2012-02-24, 20:14
  2. In E61i phone REGISTER method is not working.
    By Changeme123 in forum VoIP
    Replies: 0
    Last Post: 2008-10-01, 13:18
  3. need s60(3650) "http post method" working code
    By cumhur in forum Mobile Java General
    Replies: 5
    Last Post: 2003-12-07, 23:55

Posting Permissions

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