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 Developer
lvganesh
Posts: 16
Registered: ‎12-11-2009
My Device: 9500

Urgent help required for first of its kind health care application using blackberry widget

 

Hi Tim,

 

We are building first of its kind of blackberry widget driven emergency response application for health care providers in India.

 

We need to work with XMLHTTPRequest.

 I am requesting a web service page to get responseBody. However I am getting errors while doing the same.

 

 

Code:

function updateContent()

{

try

{

alert("UpdateContent");

var req = new XMLHttpRequest();

req.open("GET", "http://IP address/service.asmx");

req.send();

alert('request complete: ' + req.status);

if (req.status == 200)

{

displayOutput(req.responseBody);

}

else if (req.status==404)

{

displayOutput("Error: " + req.statusText);

}

else

{

displayOutput("Error: " + req.statusText);

}

 

}

catch(e)

{

alert('exception: ' + e.name + '; ' + e.message);

}

}

 

Error:

exception:undefined

the requested operation cannot be performed in the current state.

 

Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Urgent help required for first of its kind health care application using blackberry widget

There are a few items.  When you are doing a req.send() you must pass "null" as a parameter "req.send(null)".

 

Also you are using "responseBody"  when I believe the supported W3C standard XMLHttpRequest properties are "responseText" and "responseXML"

 

The other thing is that all AJAX requests by default run asynchronously so that after you do the "send" you won't have the response back.  You need to add a callback handler

 

Here is another thread that may help out:

http://supportforums.blackberry.com/t5/Web-Development/How-to-Consume-Dot-Net-Webservice-in-Blackber...

 

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter