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 Contributor
wfsdesign
Posts: 3
Registered: ‎08-07-2012
My Device: None
My Carrier: Sprint
Accepted Solution

AJAX Request Returns Status of "0"

I am building a page that makes a standard XMLHttpRequest to a php script. On all other browsers I get a status code of "200" but on Blackberry devices I am getting "0" for the status. Has anyone run into this problem? Below is the code that I am working with:

 

                            var httpRequest;
                            
                            if (window.XMLHttpRequest) { // Mozilla, Safari, ...
                                httpRequest = new XMLHttpRequest();
                            } else if (window.ActiveXObject) { // IE
                                try {
                                    httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                                }
                                catch (e) {
                                    try {
                                        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                                    }
                                    catch (e) {}
                                }
                            }
                            
                            if (!httpRequest)
                                return false;
                            
                            httpRequest.onreadystatechange = stateChange;
                            httpRequest.open('GET', post);
                            httpRequest.send();
                            
                            function stateChange()
                            {
                                alert(httpRequest.readyState + " | " + httpRequest.status + " | " + httpRequest.statusText + " | " + httpRequest.responseText);
                            }

 

Please use plain text.
New Contributor
wfsdesign
Posts: 3
Registered: ‎08-07-2012
My Device: None
My Carrier: Sprint

Re: AJAX Request Returns Status of "0"

After some research I found that the issue isn't with the JavaScript, but with the PHP proxy I'm utilizing. I'm using a post request that calls from a different domain, so I believe this is a cross domain issue. I established the PHP proxy to get around the cross domain issue, but it appears that with Blackberry it won't allow you to go cross domain even when you use a proxy. Does anyone have an idea how I can resolve this?

Please use plain text.
New Contributor
wfsdesign
Posts: 3
Registered: ‎08-07-2012
My Device: None
My Carrier: Sprint

Re: AJAX Request Returns Status of "0"

I found a solution. The problem was that the PHP proxy was calling a different domain and the blackberry device detected that I'm assuming. What I did was change my method of using CURL to just using PHPs file method and all is well now.

Please use plain text.