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
New Developer
jmaltez
Posts: 12
Registered: ‎02-18-2013
My Device: Playbook

Ajax post for unknown uri

I've developed a playbook app that allows you to control a wdtv media player on your local network via wifi. It does this via an Ajax post to a user configured ip address. The configuration.xml file has uri="*" in the access attribute.

 

The playbook app submits posts as expected.

 

When porting to BB10, I get a javascript alert indicating 'not allowed '. I understand that this happens because a XMLHttpRequest is used:

 

"If the domain requires access to APIs or accesses data through XMLHttpRequest, you must explicitly specify the domain in the uri."

 

What are my options given that the app only knows the uri at runtime?

Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C

Re: Ajax post for unknown uri

That's a good point actually

 

If you're on a private network like 192.168.x.x you shouldn't need to whitelist as there's no danger to the world at large

 

I'd stick it in as a bug report

 

I can't see an obvious way around it without a lot of messing around like forcing static IPs etc or sending it out to a server then getting it back via a PC and relaying the message

 

Not familiar with the WD kit but you could also possibly use a dynamic DNS on them

 

No simple solution comes to mind that makes it 'just work'

 




Click the like button if you find my posts useful!
BlackBerry Development Advisor
rcraigbarnes
Posts: 40
Registered: ‎01-11-2013
My Device: BlackBerry Z10

Re: Ajax post for unknown uri

I don't suggest this option in a produciton environment.. For testing you can add the following to your config.xml:

 

<feature id="blackberry.app">
    <param name="websecurity" value="disable" />
</feature>

 

This will disable web security for your application, allowing you to access any URI. http://developer.blackberry.com/html5/documentation/param_element.html

--
Website Relations - Web Technologies

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
New Developer
jmaltez
Posts: 12
Registered: ‎02-18-2013
My Device: Playbook

Re: Ajax post for unknown uri

Thanks for replying. Sounds like there is no workaround for a production version and my only option is to submit a bug?

BlackBerry Development Advisor
rcraigbarnes
Posts: 40
Registered: ‎01-11-2013
My Device: BlackBerry Z10

Re: Ajax post for unknown uri

There is nothing stopping you from using this in a Production app, but it is recommended only as a last resort,

 

--
Website Relations - Web Technologies

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C

Re: Ajax post for unknown uri

I missed the disable web security feature (handy to have)

 

In your case I think it's valid to use it for now - just validate the IP is 192.168.x.x.

 

If you do a search for Wifi on any wifi-enabled device just about all of them will be using 192.168.0.1 as their address unless the user changes the router settings

 

The issue is that on install the user will get a big pop-up saying you want to disable web security before you can say why (which makes it sound like something bad)

 

As I said - I really consider this being a bug

 

Then again it could potentially be mis-used in a public area - e.g. at a HotSpot point

 

Pinched from Wiki - The private network address space

 

RFC1918 nameIP address rangenumber of addressesclassful descriptionlargest CIDR block (subnet mask)host id sizemask bits
24-bit block 10.0.0.0 - 10.255.255.255 16,777,216 single class A network 10.0.0.0/8 (255.0.0.0) 24 bits 8 bits
20-bit block 172.16.0.0 - 172.31.255.255 1,048,576 16 contiguous class B network 172.16.0.0/12 (255.240.0.0) 20 bits 12 bits
16-bit block 192.168.0.0 - 192.168.255.255 65,536 256 contiguous class C network 192.168.0.0/16 (255.255.0.0) 16 bits

16 bits

 

 




Click the like button if you find my posts useful!