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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:27:41+00:00 2026-05-24T01:27:41+00:00

how to use the error parameter of the jquery’s $.ajax thing ? let’s say

  • 0

how to use the error parameter of the jquery’s $.ajax thing ? let’s say i have a form, and then when I submit it, the data is being saved to the table using the PHP script used in the ,

   $.ajax({
      type: "POST",
      url: "classes/ajax.submitcv.php",
      data: "userid="+userid+"&resumetitle="+resumetitle+"&resumeintro="+resumeintro+
            "&name="+name+"&dob="+dob+"&contacttel1="+contacttel1+"&contacttel1type="+contacttel1type+
            "&contacttel2="+contacttel2+"&contacttel2type="+contacttel2type+"&contacttel3="+contacttel3+
            "&contacttel3type="+contacttel3type+"&primaryemail="+primaryemail+"&secondaryemail="+secondaryemail+
            "&skype="+skype+"&facebook="+facebook+"&linkedin="+linkedin+"&twitter="+twitter+
            "&messenger="+messenger+"&yahoo="+yahoo+"&aol="+aol+"&summaryofpositionsought="+
            summaryofpositionsought+"&summaryofskills="+summaryofskills+"&gender="+gender,
      success: function(){
        $('form#wsrecruitcvhead').fadeOut("normal",function(){
           $('div.success').fadeIn(1000);
        });
      },
      });
      return false;
   });
 });

based from the code above, if the data went through the database table, the form disappears and the success message inside a tag shows, so how am I gonna output an error message instead, let’s say I have a php function and the data to be inserted returns false, how to update the html file given the message and the form won’t fadeOut ? in short..how to use the error param of $.ajax ?

  • 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-24T01:27:42+00:00Added an answer on May 24, 2026 at 1:27 am

    The error() function is used to call a function whenever the request fails. We’re going to assume that your request doesn’t fail (in an HTTP sense; that is, the request can return with an error without failing). What you need to do is have ajax.submitcv.php print out some sort of text indicating whether the data was successfully saved. Then, in your success() function, you can do something like:

    success: function(data) {
       if (data === 'success') {
           // code for success
       }
       else if (data === 'failure') {
           // code for failure
       }
    }
    

    I would recommend sending the results back as JSON. Something like:

    { “response”: “success” }

    And:

    success: function(data) {
       var returned = $.parseJSON(data);
    
       if (returned.response === 'success') {
           // code for success
       }
       else if (returned.response === 'failure') {
           // code for failure
       }
    }
    

    By the way, I’m being very general. Actual production code should check for null values and other things (and have an error handler for when requests fail).

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

Sidebar

Related Questions

I use jQuery ajax calls to ASP.Net web services (ASMX files) to update the
I have a bunch of jQuery AJAX post requests wrapped up in a for
Right now I have simple form with a single input. I'm trying to use
I have to send some data to server in JQuery and I'm lost in
In my document I have this script: $.ajax({ type:POST,url:ajax.php,data:data, success: function() { //onsuccess },
Is it possible to use the JQuery ajax method to pass parameters into a
When doing ajax requests using jQuery's ajax() function I never use any parameters other
I read somewhere that one should never use error conditions as normal program flow.
I want to use the error message returned by a RuleViolation as the validationMessage
Trying to use: :On Error exit :r D:\opt\db_objects\REPORTS\dbo.sp_ReportCountLORUsers.sql ...and I get: Msg 102, Level

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.