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
robertot5
Posts: 21
Registered: ‎06-07-2013
My Device: Blackberry Playbook & Blackberry Curve 9320
Accepted Solution

xmlhttprequest or other way

Hi,

I want to make this simple app wich basically just shows a text and a date, returned by accessing php web page on the web wich takes in 3 parameters in the URL. http://url?=param1&param2&param3.

I tried with xmlhttprequest but I just hit the cross domain restriction and I'm looking for an alternate way.

 

Any ideas ?

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

Re: xmlhttprequest or other way

Here is a sample that demonstrates how to use XHR:

http://blackberry.github.io/WebWorks-Samples/kitchenSink/html/browser/xhr.html

 

In order to enable cross-domain reqeusts, you would need to declare an <access> element in your WebWorks application config.xml file for the domain(s) you wish to access.

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.
Contributor
robertot5
Posts: 21
Registered: ‎06-07-2013
My Device: Blackberry Playbook & Blackberry Curve 9320

Re: xmlhttprequest or other way

Hi and thanks for the link.

It helped me and I got my first app using XMLHTTP working.
I am now working on how to retrieve and display only a part of the HTML page served by the server asked with XMLHTTP. The page returns a table with no ID, just a class="table_data" and I want to display to the user only the text contained in that table.
I read something about using document.getElementById but my wanted content does not have an ID to hook on, just a class and text with <b></b> tags.

Do you have any suggestions for me ?
Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: xmlhttprequest or other way

You can select an element by its class name like this:

 

var elements = document.getElementsByClassName("table_data");

var num = elements.length; //should only be 1

var first = elements[0];

 

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.