Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:04:16+00:00 2026-05-27T00:04:16+00:00

I am developing an app using phonegap for Android. I want this mobile application

  • 0

I am developing an app using phonegap for Android. I want this mobile application to send some data (mostly text) to an external server backed by cakephp, using jquery and json objects.

I am relatively new to cakephp and the MVC structure, and would appreciate some general advice on how to proceed with this in cake. I basically want phonegap to send formdata to the cakeapplication, and have cake save this data to the database. This is the code I am thinking about using for sending data in phonegap:

HTML form:

    <form method="post" id="infoForm">
       <input type="text" name="first_name" id="first_name" value="" placeholder="First Name"  />
       <input type="text" name="last_name" id="last_name" value="" placeholder="Last Name"  />   
       <input type="text" name="email" id="email" value="" placeholder="Email"  />
      <button type="submit">Submit</button> 
</form>

Jquery:

$('#infoForm').submit(function() {

    var postTo = '//url to cakeapplication';

    $.post(postTo,({first_name: $('[name=first_name]').val(), last_name: $('[name=last_name]').val(), email: $('[name=email]').val()}),
    function(data) {
        alert(data);
        if(data != "") {
            // do something
        } else {
            // couldn't connect
        }        
        },'json');
    return false;
});

Can anyone provde som general instructions on how process this data in cake?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:04:16+00:00Added an answer on May 27, 2026 at 12:04 am

    PHP5 has the json_encode() and json_decode() functions which are of great use. If you’re stuck on PHP4 I believe there’s a JSON Compenent for Cake. I can’t say much about the latter, but calling the PHP5 json_decode() will result in a PHP object which you can use to construct a Cake data array to be saved in the database.

    What you want is to have your AJAX function call a method (add() for example) in the Cake controller which handles saving data to your database. Cake’s save method expects a specially formatted array, the structure of it is detailed here, so you’ll have to manually construct this yourself.

    Say your modelised database table for PhoneGap data is called “Phonegap” (in that case you would have a PhonegapModel and PhonegapsController). The data array for saving would have the following structure:

    function add() {
      $this->data = array(
        'Phonegap' => array(
          'first_name' => 'value',
          'last_name' => 'value',
          'email' => 'value'
        )
      );
      $this->Phonegap->save($this->data);
    }
    

    The JSON object is probably available via $this->params['form'] (as per here) in the controller, as you’re performing an AJAX post. I’m not entirely sure how much you already know about CakePHP, so if some things need clarification, just let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an app using jquery mobile, phonegap and openDatabase. When the app is
I am developing an iphone app on phonegap and I am using jQuery mobile.
Am developing an app using zend framework. I want to update some columns in
I am developing an app using jqm+phonegap. I want to store the selected options
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
Am looking into developing an iPhone native app using Titanium Developer Since this is
I am developing an app using WinForms and the RichTextBox control. This control allows
I'm in the middle of developing android app using google map. My question is
This is no typical programming question. I am currently developing an app using the
I am developing an app using android OS for which I need to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.