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
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space
Accepted Solution

Problem with XMLHttpRequest and 0.9.4 on PlayBook

I'm working on PlayBook with the newest SDK 0.9.4. When I'm trying to send an XMLHttpRequest like this

 

	var myJSONObject = {'function': 'add', 'params': [parseFloat(s1), parseFloat(s2)]};
	var xmlHttp = null;
	try {
		xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e) {
			try {
				xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				xmlHttp  = null;
			}
		}
	}

if (xmlHttp) { xmlHttp.open('GET', 'http://xxx.xxx.xxx.xxx:8080/test/testservice?rpc=' + myJSONObject.toJSONString(), true); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { alert('Result is ' + xmlHttp.responseText); var jsp3 = json_parse(xmlHttp.responseText); document.getElementById("resarea").innerHTML = jsp3.result; } }; xmlHttp.send(null); }

 all I'm getting is an empty response and status==0 Smiley Sad( (it's not about the JSON object, because on the server side I can see it running correctly). If I remember correctly I think it still worked under 0.9.3.

 

Has anyone else encountered this problem? Or does anyone have an idea how to fix this Smiley Sad ?

 

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Problem with XMLHttpRequest and 0.9.4 on PlayBook

OK, after I spent the whole morning trying to fix this, I just went to get a coffee, came back, and now it works.

 

I don't know what to say to this :/

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 49
Registered: ‎02-09-2011
My Device: Not Specified

Re: Problem with XMLHttpRequest and 0.9.4 on PlayBook

Yay Coffee!!!

Developer
Posts: 178
Registered: ‎03-10-2011
My Device: Not Specified

Re: Problem with XMLHttpRequest and 0.9.4 on PlayBook

status==0 seems to mean cannnot estibalish network connectivity. maybe your simulator was hard to find detect network.

Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Problem with XMLHttpRequest and 0.9.4 on PlayBook

actually, status == 0 means 'no response'. it was strange anyway, because i could clearly see that everything on the server side worked (meaning, the server got the request, processed it and sent it back. but the callback in xmlHttpRequest was called way too early)

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o