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
New Contributor
Posts: 2
Registered: ‎12-17-2012
My Device: BB10 Dev Aplha
My Carrier: tim

Re: Method for making an HTTP style request in Cascades/QML?

i just tested it and that works...

 

in main.qml add

 

import "ajax.js" as A

then add A.get()

 

    onCreationCompleted: {
        // this slot is called when declarative scene is created
        // write post creation initialization here
        A.get("https://passborg.com/passbook/test.php");
        console.log("!!!!!!!!!!TabbedPane - onCreationCompleted()")

        // enable layout to adapt to the device rotation
        // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
        OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
    }

 

------------------------------------------

add ajax js

 

function get(url) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET",url,true);
    xhr.onreadystatechange = function()    {
        if ( xhr.readyState == xhr.DONE)        {
            if ( xhr.status == 200)            {
                var rt=xhr.responseText;
                console.log(rt);
            }
        }
    };
    xhr.send();
}

Highlighted
New Contributor
Posts: 8
Registered: ‎07-20-2013
My Device: BB Z10, BB Q10
My Carrier: Vodafone

Re: Method for making an HTTP style request in Cascades/QML?

Hi Solom,

This worked for me very good with some modifications to be compatible with the new firmware changes

But I have a little problem here, that when I tried to run the app the main qml is not started well and it keep displaying the Black Berry 10 black screen

So please would you help me to find the mistake.

Here under is my code.

 

main.cpp

 

/*
 * Copyright (c) 2011-2012 Research In Motion Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <bb/cascades/Application>
#include <bb/cascades/NavigationPane>

#include "app.hpp"

using ::bb::cascades::Application;

Q_DECL_EXPORT int main(int argc, char** argv)
{
    Application app(argc, argv);

    App mainApp;

    return Application::exec();
}

 This is the only file that you didn't provide in your code.

The problem here that when you create a new project in the latest NDK, by defualt the App.hpp and App.cpp are named "applicatioui.hpp" and "applicationui.cpp"

 

Thanks in  advance for your previous kind help Smiley Wink