Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 10
Registered: ‎10-15-2010
My Device: Blackberry 6 9800
Accepted Solution

is a HTTP Post possible using webworks/widget SDK or do i need to use Java widget?

Hi All,

 

i am using webworks and widget SDK to do a simple application where i need to do the following

 

1) open a site called www.mytest.com

2) post the following parameters along with request to open the site

 

login=true

userid=a

password=b

 

Is this possible using BlackBerry Widget SDK? I looked at the blackberry.invoke.BrowserArguments and i don't think it allows that.

 

Is this a limitation with using webworks? if yes is the only alternative is to develop a java widget and use the browser2 field?

 

Thanks,

Parag

Contributor
Posts: 11
Registered: ‎10-06-2010
My Device: 9550
My Carrier: mtn

Re: is a HTTP Post possible using webworks/widget SDK or do i need to use Java widget?

Yes you can...

When making an Ajax request, on your call to the XMLHttpRequest objects open() method use the following:

xmlhttp.send('post',url,true);

xmlhttp.send(post_string);

 

WHERE

'post' : your request method

url: the url to which you are making the http request

true: for it to be asynchronous (note: this is the default behavior)

 

post_string: is a urlencoded string containing all your post variables and their values like so

'xc='+encodeURI(element.value)+'&xd='+encodeURI(element2.value).......

 

You should be okay from here so long as you know how to create an XMLHttpRequest object and can use GET, this should be familiar.

Contributor
Posts: 10
Registered: ‎10-15-2010
My Device: Blackberry 6 9800

Re: is a HTTP Post possible using webworks/widget SDK or do i need to use Java widget?

Thanks. This solved the issue. In any case i have decided to use the Java widget as i need some more features which currently are avaliable only on java side.

 

Thanks again for your help.