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
Developer
rxan
Posts: 20
Registered: ‎02-15-2009
My Device: Not Specified

XMLHttpRequest to the client

Is it possible to have Javascript make a request to the client on which the page is running? I've been trying to use XMLHTTPRequest to the device's IP address and I keep getting error 500. I also tried localhost or 127.0.0.1 and got the same error. The page making the request is stored as a file on the blackberry.

 

This probably isn't a BlackBerry-specific thing but I figured I'd ask here anyway.

 

Thanks!

--Ryan

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

Re: XMLHttpRequest to the client

Hi Ryan,

 

To access a file on the local system, use the "file:///" protocol.  Here's an example of the path to an image file stored on removable media (SD card):

 

 

file:///SDCard/BlackBerry/pictures/image.jpg

 

 

You can also load file paths directly in the address field of the browser (e.g. to verify path is valid).

 

As a reminder, you cannot access these files if your BlackBerry is currently in mass storage mode.

 

Sincerely,

Adam

 

 

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.
New Developer
lvganesh
Posts: 16
Registered: ‎12-11-2009
My Device: 9500
My Carrier: IT

Re: XMLHttpRequest to the client

I am using "Blackberry Java Development Environment". In that I am trying to request the server(59.165.0.0)  to access data . While I am requesting the server it is giving the error that.

--> Cross origion Access Voilation.

I am requesting the server as http://59.165.80.20/abc/PhonePage.aspx  in Phone.html.

Here I am using HTMl and Javascript only to get the details from the server.

Is it possible to use xmlHTTP request in Blackberry Java Development Environment to interact with the server.

Please help me in this regard.And im new to this technology. More over all the HTML pages are stored locally. And some html pages are used from server.

 

Thanks and Regards

L.V.Ganesh

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: XMLHttpRequest to the client

Hi There,

 

I have a few questions that might help clarify your approach and possible solutions.

 

- Which version of the BlackBerry operating system are you using? 

- If it is v5.0, are you using the BrowserField or BrowserField2 API?

 

Thanks

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
lvganesh
Posts: 16
Registered: ‎12-11-2009
My Device: 9500
My Carrier: IT

Re: XMLHttpRequest to the client

Hi 

We are using Black Berry 5.0 OS. and we are using Vista OS

And we are using Browser field2

 

 

Thanks & Regards

Ganesh

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: XMLHttpRequest to the client

In order to allow cross origin XHR requests in BrowserField2, you will need to set the proper BrowserFieldConfig property.

 

There is a property called ALLOW_CS_XHR and it needs to be set to true

 

Cheers

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Contributor
caseynashvegas
Posts: 7
Registered: ‎11-02-2012
My Device: Developer
My Carrier: Developer

Re: XMLHttpRequest to the client

I am developing an application which uses the BrowserField with local HTML resources that need to access RESTful services via XMLHttpRequest (using jQuery to hide that detail).  I have set the ALLOW_CS_XHR property to true in my browser config, but the request still doesn't leave the browser control.  Any idea as to what might be wrong?

Please use plain text.