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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:17:55+00:00 2026-06-17T23:17:55+00:00

In a php script, after an attempt at a database insert, I’m returning to

  • 0

In a php script, after an attempt at a database insert, I’m returning to the calling $.ajax() function either the id of the new record or an error message:

if ($newID > 0) {
    // Successfully added new record
    echo $newID;
} else {
    // No new record was inserted
    echo 'Error: ' . mysqli_error($dbc);
}

My question is: if the php else clause gets fired and I’m passing a string via the echo, then won’t the success() function be called in the $.ajax function? Is there a way to somehow “fire” the $.ajax error() function depending on what’s passed from the php script?

  • 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-17T23:17:56+00:00Added an answer on June 17, 2026 at 11:17 pm

    $.ajax.error() shouldn’t really be fired, as the AJAX call was a success. However, I guess you could return a different header if you really wanted to:

    header("HTTP/1.0 404 Not Found");
    

    See http://php.net/manual/en/function.header.php and http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

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

Sidebar

Related Questions

After loading a PHP template (using jQuery's load function), this simple script won't make
This is my first attempt at a php script after a few weeks of
After a successful login attempt my php script starts a session like this: session_set_cookie_params(1800,'/','www.mydomain.com',true);
I want to make a button that starts my php script after I click
I have a php script that check if the referrer has been cleared after
After authorizing my app, I'm redirecting the user to my php-script: require 'facebook.php'; $facebook
I'm trying to add some error checking inside my PHP script. Is it valid
In php what is the best way to run a script after one has
With PHP and Apache, is it possible to start the PHP script after the
PHP script to read in user action requests and parse them to their components.

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.