×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Post Data from a widget

    Hi,

    I'm trying to send POST data from a form to a site. I haven't been able to test if the POST data is being sent so i don't know if the problem is in my request or in the way the server parses the data. If anyone could help that'd be great.

    Code:
     
    <form action="javascript:widget.openURL('http://my.websites/url')" onSubmit="javascript:widget.openURL('http://my.websites/url')" method="post">      
            <input name="data[Visitors][keysearch]"  class="text_field3" tabindex="1" value="" type="text" id="VisitorsKeysearch" />
            <input type="submit" name="Submit" value="  SEARCH  " maxlength="63" id="Submit" class="srch_but" />
    </form>
    Last edited by testbot; 2009-11-25 at 00:47. Reason: missing a form tag

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Post Data from a widget

    Hi testbot,

    in order to send POST requests from a WRT widget, the best approach would be to use the XMLHttpRequest object, specifying "POST" as request method. You can find several examples on Forum Nokia Wiki, as this:

    http://wiki.forum.nokia.com/index.ph...ith_JavaScript

    specifically the update() function:
    this.update = function(jsonObject){
    var jsonString = JSON.stringify(jsonObject);
    var self = this;
    this.xmlhttp.onreadystatechange=function(){
    if (self.xmlhttp.readyState==4){
    if (self.xmlhttp.status==200){
    self.onUpdateSuccess.call(self,self.xmlhttp.responseText);
    }else{
    self.onUpdateError.call(self,self.xmlhttp.statusText);
    }
    }
    }
    this.xmlhttp.open("POST",this.resource_url,true);
    this.xmlhttp.setRequestHeader("Content-type", "application/json");
    this.xmlhttp.setRequestHeader("Content-length", jsonString.length);
    this.xmlhttp.setRequestHeader("Connection", "close");
    this.xmlhttp.send(jsonString);
    }
    Other related links:

    http://www.devx.com/DevX/Tip/17500
    http://www.openjs.com/articles/ajax_...using_post.php

    Pit

Similar Threads

  1. Replies: 2
    Last Post: 2009-06-14, 09:12
  2. http post: adding multiple fields to the data
    By claudiaresa in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-07-14, 17:15
  3. Sending data by WAP POST
    By cmc77 in forum Symbian
    Replies: 0
    Last Post: 2004-08-23, 13:53

Posting Permissions

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