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 7184339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:10:52+00:00 2026-05-28T18:10:52+00:00

im trying to do a ajax port to a php file, and it seems

  • 0

im trying to do a ajax port to a php file, and it seems that is doesn’t want to send the data.

i have a android project using phone gap library and it looks like if i go a get it works:

$(document).ready(function () {

            $.ajax({ 
                type: 'GET', 
                url: 'http://example.com/functions.php', 
                data: { get_param: 'login' },
                dataType:'json',
                success: function (data) { 
                    alert('success');
                     });
                }, 
                error: function () { 
                    console.log(XMLHttpRequest.errorThrown); 
                }

            });
        });

so, this works properly. But when i try to post tome data it doesn’t:

var vals = $("#form").serialize();

                    $.ajax({ 
                        type: 'POST', 
                        url: 'http://example.com/functions.php', 
                        data: vals,
                        dataType:'json',
                        success: function (data) {
                            alert('success');
                            $.mobile.changePage( "test.html", { transition: "slideup"} );
                        }, 
                        error: function () { 
                            alert('fail');
                        }

                    });

with this previous example i get the fail alert

i’ve also tried:

   $.post("http://example.com/functions.php",  vals ,
        function(data){ //Your onsuccess call backfunction
            alert(data);  
        }, "json" //retun data type //can be html/json/xml/text
        );
        e.preventDefault();

but this fails also.

Any ideas on why the get works but not the post? Right now i have nothing returning from the php function but i should at least get the success alert.

lots of thanks

edit: the php code i have checks for the vals sent by the ajax. One of them is name

if (isset($_POST['name'])) {
    return "name";
}
  • 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-28T18:10:53+00:00Added an answer on May 28, 2026 at 6:10 pm

    Your client side code looks good. Both the $.ajax and $.post calls should successfully submit the form values to the server side script. From there on, it’s this script that executes and it might throw errors. I would recommend you using a javascript debugging tool such as FireBug in FireFox or Chrome developer toolbar in Google Chrome which allows you to monitor an AJAX request. You can see the actual request sent and the response from the server. You can see the HTTP status code returned by the server as well as the precise response. So if this status code is different than 200 (which is your case) the error callback will execute on the client. So go debug and fix your functions.php server side script.

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

Sidebar

Related Questions

I'm trying to AJAX-ify the Django contact_form app using Django (1.4.2). I want to
I am trying AJAX for the first time for my school project. I have
I'm trying ajax for the first time but it doesn't work. This is some.php
I have a Pylons app that I'm trying to set up using Apache and
I am trying AJAX for the first time on my localhost. I am using
I'm trying to run .ajax and insert a data element from the onClick of
In trying to solve the ajax back button problem I have found the Really
Im trying to create an ajax (post) event that will populate a table in
I'm trying to port a portion of AJAX code I wrote over to the
I'm trying to use jQuery to run an AJAX query on a specific port:

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.