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
Trusted Contributor
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

WebWorks Application Can't request to web server

[ Edited ]

I tried to make a blackberry webworks application using eclipse. In my application, I use jquery to my request to my server to get and send data.

I have tried on the ripple emulator and it run normaly and fine . it's just that after I tried the eclipse was in trouble. My application can not connect to my server. Error in blackberry emulator with eclipse.

What should I do?
Is there a difference between the ripple emulatorand the eclipse IDE?

My script :
<script language="javascript">
  
    $(document).ready(function(){
        $("#submit").click( function (){
            var username = $('#username').val();
            var password = $('#password').val();
            var token="";
            var nama="";
            var status="";
            var lastlogin="";
           
            if(username !='' && password !=''){
                if (username.indexOf("\"") != -1 || username.indexOf("'") != -1 || username.indexOf("<") != -1 || username.indexOf(">") != -1){
                    jAlert('Ada karakter aneh di field username', 'Forbiden Rules');
                    }
                     else{
            $.ajax({
               type: "POST",
               url : 'http://www.berthojoris.com/dev/jqm/login_cek.php',
               cache: false,
               data: {
                  username:$('#username').val(),
                  password:$('#password').val(),
               },
               dataType: "json",
               success: function (data) {
                    if (data.response=='SuksesLogin') {
                        token = $(data.detail);
                        nama = $(data.nama);
                        status = $(data.status);
                        lastlogin = $(data.lastlogin);
                       
                        localStorage.setItem("token",data.detail);
                        localStorage.setItem("nama",data.nama);
                        localStorage.setItem("status",data.status);
                        localStorage.setItem("lastlogin",data.lastlogin);
                        ClearForm();
                        self.location="menu_admin.html";
                    } else {
                        jAlert('Username dan Password tidak cocok', 'Login Failed');
                        ClearForm();
                    }
                },
                error : function(data) {
                       jAlert('Koneksi anda sedang bermasalah.', 'Check Connection');
               }
      });
                    }// Ini tutup else jika Ada karakter aneh

                }else{
                    jAlert('Field masih ada yg kosong', 'Field Empty');
                    document.forms["login"]["username"].focus();
            }
       
    });
});
</script>

Regards,
Bertho
Highlighted
Developer
Posts: 161
Registered: ‎02-08-2012
My Device: PlayBook
My Carrier: None yet

Re: WebWorks Application Can't request to web server

Do you have the address you're trying to get to whitelisted in your config.xml?
Trusted Contributor
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

Re: WebWorks Application Can't request to web server

I am a new programmer who is still learning how to make blackberry application. Can you help me how to add a whitelist in the config.xml file?
URL that I use is: http://www.berthojoris.com/dev/jqm/login_cek.php

Regards,
Bertho
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: WebWorks Application Can't request to web server

You need to tell your application which domain it has access to. This is done by adding access elements to your application's config.xml file.  The documentation for this can be found here:

https://bdsc.webapps.blackberry.com/html5/documentation/ww_developing/working_with_config_xml_file_1...

 

Here is an example config.xml file.  This application has access to any content that is downloaded from http://devblog.blackberry.com AND http://www.twitter.com:

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns=" http://www.w3.org/ns/widgets"
		xmlns:rim="http://www.blackberry.com/ns/widgets" 
		version="1.0.0.1" id="sample">
	
	<name>sample</name>
	
	<content src="index.html"/>	
	
	<access uri="http://devblog.blackberry.com" subdomains="true"/>  
	
	<access uri="http://www.twitter.com" subdomains="true" />	
	
</widget>

 

Note : You can also whitelist ALL urls by using the following wildcard character  (recommended only for testing - for production code, you should always define only those URLs your application needs):

 

<access uri="*" subdomains="true"/>

 

Happy coding.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Trusted Contributor
Posts: 100
Registered: ‎03-31-2012
My Device: Blackberry 9780
My Carrier: Telkomsel

Re: WebWorks Application Can't request to web server

I have tried what is passed on to me. But I still find it difficult to make requests to the server. I use JQuery always go to the :


error : function(data) {
                       jAlert('Your connection failed.', 'Check Connection');
               }


What should I correct in my code so that my application can connect to my server?

I want to ask if I write code using jquery it is correct or is wrong?
Please help ...

Regards, Bertho



Regards,
Bertho