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

  • SEARCH
  • Home
  • 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 6835775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:16:23+00:00 2026-05-26T23:16:23+00:00

I am developing an app in phonegap, and I am trying to pass formdata

  • 0

I am developing an app in phonegap, and I am trying to pass formdata from phonegap to a remote server with jquery and json and save it to the mysql database.
I have never used json before, and I am really uncertain of how to recieve and parse this data on the server.

Could anyone help me write a simple php script to handle this?

This is the form and jquery I am using to send data:

<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>

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

    var postTo = 'http://siteurl.com';

    $.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;
});

I have been trying to find a solution for hours without any result.

Thank you!

  • 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-26T23:16:24+00:00Added an answer on May 26, 2026 at 11:16 pm

    First of all you can avoid structure like this:

    {first_name: $('[name=first_name]').val(), last_name: $('[name=last_name]').val(), email: $('[name=email]').val()}
    

    With jQuery’s built in serialize method:

    $.serialize(this)
    

    As far as you already specified “json” as a response type “data” variable will contain already unserialized JSON object.

    In php script side of things you need to do following:

    echo json_encode($_POST);
    exit();
    

    Of course you need to change $_POST superglobal with your array/object of result, I used it for demo purpose in script line above.

    Obviously $_POST variable contains data passed from Ajax request, such variable is available in any scope in PHP script.

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

Sidebar

Related Questions

I am developing phonegap app in iphone,after successfully viewing pdf file (from server) on
I am developing a Android app using Jquery Mobile/Phonegap. I have the following code
I'm developing web app that user can save his/her work to server. The data
I'm developing an app using jquery mobile, phonegap and openDatabase. When the app is
I am developing an app using PhoneGap 1.2.0 and Xcode 4. I have a
I am developing an iphone app on phonegap and I am using jQuery mobile.
I have a running JQueryMobile App that Im developing with PhoneGap for Android/IPhone, and
While developing my app I have come to realize that the majority of my
I have been developing an app in VB.NET which requires a control object (for
I'm developing an HTML5 app using PhoneGap + JqueryMobile. My problem is when I

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.