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
Trusted Contributor
maanbhati
Posts: 236
Registered: ‎07-28-2010
My Device: Not Specified
My Carrier: Software Developer
Accepted Solution

How to make an http request with string parameter in BB10 development using WebWorks.

Hi All,

           I am developing an BB10 application using Webworks framework , in that i want make an http request by appending some string parameter. which type of http request i will use. any code base help.

 

 

Thanks to All

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: How to make an http request with string parameter in BB10 development using WebWorks.

Use the XmlHttpRequest JavaScript object to make a GET request to a remote URL.

 

https://github.com/blackberry/WebWorks-Community-Samples/blob/master/kitchenSink/js/browser/xhr.js

 

Here is an example:

 

var url = "http://www.yourwebsite.com/index.asp?foo=bar"
var xhr = new XMLHttpRequest();

xhr.open('GET', url, true);

xhr.onreadystatechange = function(e) {
	if (xhr.readyState === 4) {
		if (xhr.status === 200 || xhr.status === 0)  {
			console.log(xhr.responseText);
		}
		else {
			console.log("Error (" + xhr.status + "): " + xhr.statusText);
		}
	}
};

xhr.send(null);

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: How to make an http request with string parameter in BB10 development using WebWorks.

Always use POST if you can

 

I've not tried overloading BB10 in this specific way (different topic)

 

Using GET is dangerous as Google etc track URLs

 

Lets say my username is fred and my password is bloggs

 

Now - The GET URL will look something like this....

 

http://nowhere.com/?user=fred&pass=bloggs (this is a complete fake for example)

 

Now consider the same thing with a POST

 

That just goes to http://nowhere,com

 

I am oversimplifying this to make it easy (my several paragrphs on security were no real help)

 

I think I may start a blog - I detest the things - but have several servers so blog (eek) is easy so I  can address the many failings in this specific asnwer

 

 

 

 




Click the like button if you find my posts useful!
Please use plain text.