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
Highlighted
Contributor
Posts: 19
Registered: ‎11-18-2010
My Device: touch 9800,9700
Accepted Solution

Problem to post data to php file in widget.

 

        I am new in blackberry developement world.

 

       I am creating application which is posting data to mysql server. at my remorte server i have created php file. i have to send the data to that php file. I search a lot for any sample code which help but i diden't find it.

 

       Please help if it possible regarding it.

 

      I have developed application in Blackberry widget.

 

     My os version is windows 7.

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

Re: Problem to post data to php file in widget.

Have you whitelisted the domain that you are wishing to access in the <access> elements in the widget's config.xml file.  To access outside domains you must whitelist them.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 19
Registered: ‎11-18-2010
My Device: touch 9800,9700

Re: Problem to post data to php file in widget.

     Yes i have given domain name in the config.xml file. after that what is the process to send the data in url to push them to the php file in my domain server.

 

      In the discription, i have declare the domain in the config.xml file.but i have not any kind of konwladge how to call that file in my html part or any were else.Because my database is in mysql and php files are in my remourte server .so i have to send the data to that php file.

 

     please help,and give sample if it is possible.

 

     Thanks in advance.

Developer
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Problem to post data to php file in widget.

[ Edited ]

I still don't  get it what you mean about send data to the server,

but in my thought, the simple POST data is just something like simple form in your html widget:

 

 

<form method="POST" action="http://yourserver.com/file.php">

<input name="firstname" type="text" />

<input name="lastname" type="text" />

<input type="submit" value="Submit" >

</form>

 

 

Contributor
Posts: 19
Registered: ‎11-18-2010
My Device: touch 9800,9700

Re: Problem to post data to php file in widget.

 

         Thanks agungeddy for reply,

 

              I am explain you in deep.

 

              I got a task to check,add,delete,update data from the data base and my database is created in mysql. and i have created php files to do this all process. so that i have to send the data as url to my php file and at that file the data will be checked and update. so i have no idea how to send the data with my url to the server in my blackberry widget application. i have already using same method which is given by you in the past post.but after that the request has send to the file,  but i have not get the method or sample for how to store that response and do the further process for that.

 

            Sorry for bad english.

 

            Thanks in advance. 

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

Re: Problem to post data to php file in widget.

Submitting data to your php file is no different in a widget/webworks app than a regular web page in a browser.

You can either send it via a form submit like outlined above or use AJAX.
Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 19
Registered: ‎11-18-2010
My Device: touch 9800,9700

Re: Problem to post data to php file in widget.

 

       Thanks for reply,

 

                   But i have already send request to the server. after request to the server the server is not getting the response back.

 

                   I also have try to develop with Ajax and my ajax call code is as given below:

 

                    function login_btn(){

                                var username = document.getElementById("username");
                                var password = document.getElementById("password");
                                jquery.ajax({
           
                                                url:   "http://www.myurl/my.php",
                                               type:  "post",
                                               data:  "username="+username+"&password="+password+,
                                               success:function(msg)
                                                                {
                                                                           alert(msg);
                                                                }
                                   });

                    }

              From the above code discription of code is as given:

 

                1. i have declare one javascript function with button onclick id.

                2. after that store the id of the html variable field.

                3. after that as given above code when i call the ajax finction with jquery and send the data to the given url after that i have return the to print the responce message.

 

              Nothing can be happen i the simulator no any kind of responce is their from the server.

 

              Please help me i am very afraid about it.

 

              please help me if their is any other method . or if it possible please give me any sample code link or any sample code.

 

             Thanks in advance.

Developer
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Problem to post data to php file in widget.

Could be something mistaken in your JQuery Ajax method, because i know nothing about JQuery, just try another simple regular Ajax method (XMLHttpRequest)

 

Contributor
Posts: 19
Registered: ‎11-18-2010
My Device: touch 9800,9700

Re: Problem to post data to php file in widget.

 

   Thanks for the reply,

 

        I have solved that by now when i am running the application i am getting the following error now,

 

                 It says :

 

                    The resource- http:// my url/ - could not be retrieved because it was not found in the config.xml.  

 

                    Please verify the <access> elements in the widget config.Contact your service provider if the problem persists.

 

                    This type of error is accure when i am running the application.

 

                    Please give me solution if you know.

 

                    Thanks in advance.

 

Developer
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Problem to post data to php file in widget.

 


hrushikesh wrote:

 

   Thanks for the reply,

 

        I have solved that by now when i am running the application i am getting the following error now,

 

                 It says :

 

                    The resource- http:// my url/ - could not be retrieved because it was not found in the config.xml.  

 

                    Please verify the <access> elements in the widget config.Contact your service provider if the problem persists.

 

                    This type of error is accure when i am running the application.

 

                    Please give me solution if you know.

 

                    Thanks in advance.

 


 

See here for the reference about access element in config.xml"

 

http://docs.blackberry.com/en/developers/deliverables/20977/Access_element_834677_11.jsp