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
Contributor
Posts: 43
Registered: ‎09-26-2011
My Device: Bold 9700
My Carrier: Generic

Problem with web service on simulator

Hi all. i really need you are help, i have a file called index.html that contain "about" menu. Im using xml http request to display about.php on my web server when user press the "about" menu. on ripple emulator about.php is successfuly displayed, but when im try it on 9800 simulator, i can displayed about.php on my simulator,

 

what should i do to fix this? i really need you all help, so much thanks 

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Problem with web service on simulator

Is that the only call you're making that connects to the Internet? Make sure you're running the MDS simulator before you boot the device simulator. I usually visit google.com in the browser to verify the simulator has Internet conectivity too.

Contributor
Posts: 43
Registered: ‎09-26-2011
My Device: Bold 9700
My Carrier: Generic

Re: Problem with web service on simulator

Thanks for your reply sir, i have to visit google.com on my device simulator, and my device simulator can connect to that site, what should i do sir?

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Problem with web service on simulator

If the XHR is failing, you should retrieve the xhr.status and xhr.statusText, where 'xhr' is your XMLHttpRequest object, to help narrow down the error. You can add them to an alert or print to screen for example. 

Contributor
Posts: 43
Registered: ‎09-26-2011
My Device: Bold 9700
My Carrier: Generic

Re: Problem with web service on simulator

This Is My XHR Code Sir

 

<script language="javascript">


function getXMLHttpRequest(){
if(window.ActiveXObject){
return new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
return new XMLHttpRequest();
}else alert("Status : Can not create XMLHttpRequest Object");
}
var xmlhttp=getXMLHttpRequest();
function sendRequest(pageURL,ElementID){
var obj=document.getElementById(ElementID);
obj.innerHTML='Loading.... please wait.';
if(xmlhttp.readyState==4 || xmlhttp.readyState==0){

xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
obj.innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET',pageURL,true);
xmlhttp.send(null);

}

}

function tempa(){

document.getElementById('tulisan').value='About Us';

}
</script>

 

On Ripple Is Success To Display, But On Device Simulator on screen just tell me 'Loading.... please wait.'

So much thanks for your attention sir, what should i do to solve this?

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Problem with web service on simulator

[ Edited ]

I'd remove the check : if (xmlhttp.readyState==4 || xmlhttp.readyState==0)

 

And find your error:


if(xmlhttp.readyState == 4 && xmlhttp.status == '200' )
{   
    //success
}
 else
{
    //failure, find out what happened
    alert("Status: " + xmlhttp.status);
    alert("Error text: " + xmlhttp.statusText);
}  

 

Edit: Do you have the rim:connection directives in your config.xml and your server whitelisted via <access>? 

Highlighted
New Contributor
Posts: 3
Registered: ‎09-11-2011
My Device: Blackberry 9800
My Carrier: generic

Re: Problem with web service on simulator

[ Edited ]

This is my xml.config sir, so much thanks for your check, please correct me if im wrong

 

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns=" http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="2.0" rim:header="RIM-Widget: rim/widget">

<rim:navigation mode="focus"/>
<name>MyApp</name>

 

<description>
My App Applications.
</description>

 

<rim:loadingScreen backgroundColor="#FFFFFF" backgroundImage="background.png" onFirstLaunch="true" onLocalPageLoad="true"/>
<rim:transitionEffect type="zoomIn"/>

<icon src="image/front.png"/>
<icon src="image/hover.png" rim:hover="true"/>

 

<content src="index.html"/>

 

<access uri="http://www.mywebservice/about.php"/> #my web service

 

<feature id="blackberry.system.event"/>

<feature id="blackberry.push"/>

<feature id="blackberry.ui.menu"/>
<feature id="blackberry.app"/>
<feature id="blackberry.app.event"/>
<feature id="blackberry.system"/>

 

<rim:connection timeout="25000">
<id>BIS-B</id>
<id>MDS</id>
<id>TCP_WIFI</id>
<id>TCP_CELLULAR</id>
<id>WAP2</id>
<id>WAP</id>
</rim:connection>

</widget>

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Problem with web service on simulator

You have to check your xhr status and statusText to find out more.

Contributor
Posts: 43
Registered: ‎09-26-2011
My Device: Bold 9700
My Carrier: Generic

Re: Problem with web service on simulator

My config.xml is correct or not sir? i have to include your script xhr, but on my device simulator just tell "loading please wait" sir, :-( so much thanks sir for your attention

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Problem with web service on simulator

[ Edited ]

In your config.xml, change this:

 

<access uri="http://www.mywebservice/about.php"/>

 To this:

<access uri="http://www.mywebservice.com" subdomains="true"/>

 

Hopefully somebody else can chime in with ideas, I can't think of anything else at the moment.