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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:05:03+00:00 2026-06-14T23:05:03+00:00

I am trying to use jQuery for the first time, and my POST function

  • 0

I am trying to use jQuery for the first time, and my POST function using .ajax is giving me grief.
The POST is successful; my PHP page runs the MySQL query correctly and the newly created user ID is returned. The only problem is that instead of running the ‘success’ function; it simply loads the PHP page that I called, which simply echoes the user ID.

Here’s the jQuery function:

function register() {
$.ajax({
    type: "POST",
    url: 'sendRegistration.php',
    data: dataString,
    datatype: 'html',
    success: function(response){alert(response);},
    complete: function(response,textStatus){console.log(textStatus);},
    error: function(response){alert(response);}
});
}

… and the PHP return stuff:

    // Create a new send & recieve object to store and retrieve the data
    $sender = new sendRecieve();
    $custId = $sender->submitUser($userVars);
    if ($custId != 0) {
        echo $custId;
    } else {
        echo "Database connection problems...";
    }

The database object is created, and then the php page from the ‘url’ parameter loads, displaying the id that the $sender->submitUser() function returns.

Ideally, I would like it to never display the ‘sendRegistration.php’ page, but run another js function.

I’m sure there’s a simple solution, but I’ve not been able to find it after hours of searching.

Thanks for your help.

  • 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-06-14T23:05:04+00:00Added an answer on June 14, 2026 at 11:05 pm

    You are likely handling this from a form. If you don’t prevent the default form submittal process of the browser, the page will redirect to the action url of the form. If there is no action in form, the current page will reload, which is most likely what is happening in your case.

    To prevent this use either of the following methods

    $('form').submit(function(event){
        /* this method before AJAX code*/
        event.preventDefault()    
    
            /* OR*/
    
          /* this method after all other code in handler*/
          return false;
    })
    

    The same methods apply if you are sending the AJAX from a click handler on the form submit button

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

Sidebar

Related Questions

I am using HMVC codeigniter. I am trying to use jquery ajax first time.
I'm having all kinds of grief trying to re-use a jQuery-UI dialog. First time
I'm using (trying to use) jQuery to add a class to the first paragraph
This is my first time really trying to use jQuery for my personal portfolio
I'm trying to use for the first time the autocomplete feature of jquery ui,
Good day! I am trying to use jquery for the first time. And i
I using a Ajax-Enabled Wcf service for the first time trying to test a
I'm trying to use jQuery UI tabs much like a Master Page in ASP.Net.
first of all, thanks for your time. I'm trying to use jqGrid to make
I'm trying to use the PHP json_encode function to encode some JSON to send

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.