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

Posts: 116
Registered: ‎03-15-2011
My Device: Blackberry 9800
My Carrier: developer
Accepted Solution

xmlHttpRequest is returning no response in blackberry 10 webworks



I am using below link to send an http get request in blackberry webworks application. 




Calling updateContent (http://www.google.com) on click of button.


I have whitelisted the url in config.xml.

Now getting response as blank and req.status as 0.


Please let me know what I am doing wrong.



Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: xmlHttpRequest is returning no response in blackberry 10 webworks

[ Edited ]

Based on some testing:


<!DOCTYPE html>
		<script type="text/javascript">
			/*global window, document, console, alert, XMLHttpRequest */

			window.addEventListener('load', function () {
				var xhr;

				xhr = new XMLHttpRequest();
				xhr.open('GET', 'http://www.domain.com', true);
				xhr.onreadystatechange = function () {
				xhr.onload = function () {
			}, false);


Where I've substituted http://www.domain.com with various URLs, I am seeing a readyState 4, status 0 come up often when there is a security violation due to cross-domain requests. This is not something that can exactly be fixed on the client side if the server is denying that sort of access.


When I made the request to a domain on the same server that was hosting the above sample index.html, the request worked just fine.


You can test this further here:



Note that a request to http://www.google.com results in an error, while a request to https://cors-test.appspot.com/test succeeds.



EDIT: What this amounts to then is that the destination server likely is not allowing Cross-Origin requests, and you simply won't be able to make the request to that URL.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.