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

Native Development

Reply
Highlighted
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

How can we make Http request to Fetch JSON Data in QML

Hi,

 

I want to make a http request from QML to get some JSON data from Server. I have done this binding C++ and QML. But I am willing to do this using QML only.

 

 

I have found some references over Net for XMLHttp request - http://supportforums.blackberry.com/t5/Cascades-Development/Method-for-making-an-HTTP-style-request-...

 

Justto confirm is it possible for JSOn or others as well, If anybody has succeded in this?

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: How can we make Http request to Fetch JSON Data in QML

Any comments from BB experts are really appreciable..

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: How can we make Http request to Fetch JSON Data in QML

From what I can see, I'm afraid not. BB10's main class for parsing JSON data, JsonDataAccess, doesn't have any methods exposed to QML. I'm not too familiar with making HTTP requests via QML, and it may be possible to roll your own parser in Javascript, but you'd be losing a lot of conveniece if you wanted to stick purely to QML.



Did this post help you? If so, please make sure to "like" it!
Developer
Posts: 207
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: How can we make Http request to Fetch JSON Data in QML

You do NOT EVER NEVER EVER want to do an HTTP request in the UI.  You want to do network requests and other processes that need to be backend threads to be in C++.  Its a bad idea to do it in QML even if it was possible.

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Developer
Posts: 49
Registered: ‎11-11-2012
My Device: z10 LE
My Carrier: Digi

Re: How can we make Http request to Fetch JSON Data in QML

[ Edited ]

Should be doable. I use parse.com for backend and for a 'entirely QML' app, use AJAX xhr (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest) in my QML.

 

See examples (http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp).

 

You can use 'limited' JS so test that (works for me).

 

The request can be 'async' with callback, so should not take too much UI time.

 

 

If you are familiar with JS and want to do more e.g. using JQuery, html etc, then you can consider a QML+hybrid HTML5 webview to use lots more JS stuffs with your JSON data.



James Tan
Eating my dog food - TripLogger, my 1st bb10 app.
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: How can we make Http request to Fetch JSON Data in QML

Thanks James,

 

I will try what you have suggested, and will post the results..

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro