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

Android™ Runtime Development

Reply
New Contributor
Posts: 8
Registered: ‎03-27-2013
My Device: BlackBerry 10 Dev Alpha

How to not interpret the preflight in ajax on BB10?

Hello !

I converted and deployed my android application with the eclipse plugin to the extension .BAR for a smartphone BB10.

It's a hybrid application, which contains an in-app-broswer with an application html+css+js(jquery) and it's working on android, iphone, and platform bb before bb10 .

 

I do an AJAX CROSSDOMAIN request with jQuery like this:

 

$.ajax({
             type: "POST",
             url: "http://***************************.json",
             datatype: "json",
             crossDomain: "true",
             contentType: "application/json",
             data:'{"technicalNumber":"********","password":"****"}',
             scriptCharset: "utf-8",
             success : function(data) {
                    // do stuff
             },error: function(object, status, error){
                   // do other stuff
                   alert(error);
             }
}) ;

 

This POST call on a different domain, is subject to CORS concept, a preflight OPTIONS request is sent first.
The answer to this query returns an xml OPTIONS (with no value), which is interpreted and creates a type error at parseError JQuery.
 
On all other mobile platforms, the preflight request (OPTIONS) is not interpreted.

My ask is how to not interpret the preflight in ajax on BB10?

 

Thks in advance,

Ben

 

FYI:

In the manifest android there is permission to acces internet:

<uses-permission android:name="android.permission.INTERNET"/>

I configured my server to accept crossdomain requests:

# Allow origin for All / please uncomment the following lines :	
  Header set Access-Control-Allow-Origin "*"
  Header set Access-Control-Allow-Methods "POST,GET,DELETE,PUT,OPTIONS"
  Header set Access-Control-Allow-Headers "origin, method, content-type"

 

New Contributor
Posts: 8
Registered: ‎03-27-2013
My Device: BlackBerry 10 Dev Alpha

Re: How to not interpret the preflight in ajax on BB10?

More informations abour error: