02-14-2013 02:01 AM - edited 02-14-2013 02:11 AM
"resource does not exist" message was shown when i tried to run my app on my device.
here's my config.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<!--
Widget Configuration Reference:
http://docs.blackberry.com/en/developers/deliverab les/15274/
-->
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="2.0.0.1">
<name>MyRelationLoc</name>
<author>SeptaRD</author>
<description>
My Relation Loc BlackBerry WebWorks Application
</description>
<license href="http://opensource.org/licenses/alphabetical">
</license>
<!-- WebWorks API -->
<feature id="blackberry.system" required="true" version="1.0.0.0" />
<feature id="blackberry.find" required="true" version="1.0.0.0" />
<feature id="blackberry.identity" required="true" version="1.0.0.0" />
<feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
<feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
<feature id="blackberry.io.file" required="true" version="1.0.0.0" />
<feature id="blackberry.utils" required="true" version="1.0.0.0" />
<feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
<feature id="blackberry.app" required="true" version="1.0.0.0" />
<feature id="blackberry.app.event" required="true" version="1.0.0.0" />
<feature id="blackberry.ui.menu" />
<feature id="blackberry.ui.dialog" />
<!-- PhoneGap API -->
<!-- Expose access to all URIs, including the file and http protocols -->
<access subdomains="true" uri="*"/>
<access subdomains="true" uri="http://septard.cu.cc"/>
<access subdomains="true" uri="http://myloc.site90.com"/>
<access subdomains="true" uri="http://www.myloc.site90.com"/>
<access subdomains="true" uri="file:///store/home" />
<access subdomains="true" uri="file:///SDCard" />
<access subdomains="true" uri="http://gstatic.com"/>
<access subdomains="true" uri="http://google.com"/>
<access subdomains="true" uri="http://googleapis.com"/>
<icon rim:hover="false" src="resources/iconTA.png" />
<icon rim:hover="true" src="resources/iconTA-hover.png" />
<rim:loadingScreen backgroundColor="#000000"
foregroundImage="resources/loading-screen.png"
onFirstLaunch="true">
<rim:transitionEffect type="fadeOut" />
</rim:loadingScreen>
<rim:permissions>
<rim:permit>read_geolocation</rim:permit>
</rim:permissions>
<rim:navigation mode="focus" />
<content src="index.html" />
</widget>
and here's the page that trying to get data from my web server :
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var txttmp = xmlhttp.responseText;
//alert(txttmp);
var obj = $.parseJSON(txttmp);
var teks2 = document.getElementById("tbprofiluser");
teks2.innerHTML="";
teks2.innerHTML+="<tr><font size='-1'><td width='25%' align='center'><img src='http://localhost/tugasakhir/image/"+obj.user. foto+"' width='60px' height='60px'/></td><td width='75%'><b>Name : "+ obj.user.nama+"<br/>Lives in : "+obj.user.alamat+", "+obj.user.kota+", "+obj.user.negara+"<br/>Phone : "+obj.user.phone+"<br/></b></td></font></tr>";
//teks.innerHTML += "<font color='red'>"+obj.user.foto+"</font>";
}
}
xmlhttp.open("POST","http://septard.cu.cc/forjson.php",true);
xmlhttp.setRequestHeader("Content-type","applicati on/x-www-form-urlencoded");
xmlhttp.send("tmpid="+iduser+"&proses=showprofil") ;
and finally here's my forjson.php file on the web server that can access the database on the server :
<? ob_start(); ?>
<? header('Access-Control-Allow-Origin: *');
$con = mysql_connect("mysql.idhostinger.com","u846086613_ root","getbacker");
if (!$con)
{
die(mysql_error());
}
$db=mysql_select_db("u846086613_dbta",$con);
if($_POST[proses]=="showprofil")
{
$id = $_POST[tmpid];
$sql="Select a.*, b.nama_kota,c.nama_negara from t_user a, t_kota b, t_negara c where id_user = ".$id." and a.id_kota=b.id_kota and c.id_negara=b.id_negara";
$hasil=mysql_query($sql);
if(mysql_num_rows($hasil)>0)
{
$json = '{"user":{';
while($pick=mysql_fetch_array($hasil))
{
$json .= '"nama":"'.$pick[nama].'","alamat":"'.$pick[alamat ].'","phone":"'.$pick[phone].'","sex":"'.$pick[sex ].'","birthday":"'.$pick[tgl_lahir].'","foto":"'.$ pick[picture].'","kota":"'.$pick[nama_kota].'","ne gara":"'.$pick[nama_negara].'"';
}
$json .= '}}';
echo $json;
}
}
?>
<? ob_flush(); ?>
FYI : my app works just fine on the Ripple emulator, using OS 7 Platform, and the device was using BB OS 7.0 too
can anyone help me??? Thanks for any help ![]()
.Septa RD.
02-19-2013 03:52 AM
up.. please helpp meeeeee
02-19-2013 03:18 PM
Hey,
Without knowing the details of your code, may I suggest you try loading the JS into a simple index.html file on your local system and try it? If the JS is served locally (i.e. part of your application folder) then it may be subject to the same-origin policy, which would prevent the request from being served if the JS is not from the same server as the url in your xmlhttp request.
Hope it helps,
dSolver
02-25-2013 04:30 AM
how to solve that "same-origin" restrain????????? T_T
i thought the "<access subdomain='true' uri='*'>" can solve that problem ~_~a...help me ~_~
02-25-2013 08:04 AM
You see that line with xmlhttp? These server these requests goes to has to be from the same server the javascript is loaded from in order to be considered same-origin. There are ways to get around it, look into JSONP, or perhaps since you always need a connection to the server, load the JS from your server each time you need it. i.e. <script src="yourserver/..."></script>
02-25-2013 08:30 PM
ahh okay sir, i'll try it...thanks for your help