Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
rxan
Posts: 20
Registered: 02-15-2009

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
astanley
Posts: 712
Registered: 07-02-2009
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
-------------------------------------------------------------------------------------------------------------------------
BlackBerry WebWorks Developers: Join us for the BlackBerry 10 Jam World Tour May-Aug 2012.

Don't forget to check the BlackBerry Development Knowledge Base for helpful learning resources.
Please use plain text.
New Developer
lvganesh
Posts: 16
Registered: 12-11-2009
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,555
Registered: 10-16-2008
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 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,555
Registered: 10-16-2008
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.