If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Anyone know how to get around this?

 

I'm running chrome with web security disabled (so it will do cross-domain requests). 

Code: 

 

$.getJSON(url, function(data) { ... });

 

Runs fine in bare Chrome but with Ripple enabled I get:

 

webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP. 

 

Any ideas?

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Hey Marco,

 

Have you tried using the basic $.get() JQuery method?

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

That's to fetch HTML dom elements...

 

http://api.jquery.com/get/

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Hey Marco,

 

The file you are trying to retreive, won't that output json formatted text? You could then go on and do $.parseJSON(data) on the data that's retreived and go from there.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

hey maco,

 

just an update -- this will probably yield you the same results:

 

$.get(url, data, callback, "json");

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Yeah it's JSON. I'll try to go with regular AJAX and then parse it like you suggest. That said, I still don't understand why this is happening in Ripple but not in Chrome without Ripple... Makes no sense.

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Hey Marco,

 

I think it's happening because of the way Ripple handle's cross domain calls. It has this built in feature when it uses a Proxy server for all cross domain calls that devs make via their apps through ripple. This is in place for people who don't use the extra security arguments when loading up chrome. I think this "feature" is interfering with your development.

 

Chances are your code is perfectly fine and will run on the actual device. It's just the emulator that's giving you hiccups. Good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Maybe you're right. I just tried changing it into using $.get() but I'm getting the exact same error.

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

That's the strangest thing -- it shouldn't flare up with that issue because you aren't doing a JSON specific call. Is there anyway you can write out a sample of the code you are running? Just want to replicate it. Thanks!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: webworks.bb10 :: XMLHttpRequest :: setRequestHeader does not work with JSONP.

Ok it's definitely Ripple ruining the party. Just installed it on device and it's working fine on there...

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.