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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:18:46+00:00 2026-06-06T02:18:46+00:00

Here is how I am submitting my ajax request : $.ajax({ url: myurl, type:

  • 0

Here is how I am submitting my ajax request :

$.ajax({
            url: "myurl",       
            type: 'POST',
            dataType : "text",
            data : ({
                json : myjson
            }),
            success : function(data) {

                if(data == 'success'){
                    //alert('success');
                }
                else {
                    alert('fail');
                }

                };
            }

        });   

Within java im just returning the string which contains either ‘success’ or ‘fail’ depending on wether or not a exception is thrown :

pseudo code :

try {
return "success";
}
catch (Exception e){
return "fail";
}

Will this suffice instead of using the ajax error callback ? If not sufficient how should this callback be used and what extra failure conditions is it checking for ?

   error : function() {
                alert ('error');
    } 
  • 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-06T02:18:49+00:00Added an answer on June 6, 2026 at 2:18 am

    The purpose of error callback is different: jQuery will call that function if an error occurred during sending request or receiving a response. For example, if your server doesn’t return an answer but instead “500 Internal Server Error” (or any other error for that matter), then success callback function will not be called at all. If you define the error callback, then it will be called – and you’ll have some chance of figuring out what the error was.

    Just because your server works perfectly doesn’t mean that a communication error cannot occur: for example, it could be “Gateway timeout”, “No route to host”, etc.

    Finally, if you declare dataType: json (I know it doesn’t apply in your example) but the returned data cannot be parsed (i.e. it’s not a well-formatted JSON string), your error function will be called and not your success function.

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

Sidebar

Related Questions

I have a form which uses ajax for data submitting. Here is the html:
I'm having trouble submitting an ajax request. I've tried to set it up pretty
the form is submiting as normal request instead of Ajax. $(document).ready(function () { StatusComments();
Here is my code in my jquery/javascript that is performing the ajax request... else
I'm submitting an Ajax form but when it hits the controller the Request.IsAjax returns
Here is a snippet from a Sinatra app where users will be submitting urls.
Here's the problem, I need to validate the form before submitting in the next
After trying to format my JSON data by hand in javascript and failing miserably,
I have a page where the user sends data (via ajax) to a php
I want to interrupt and prevent a form from submitting using jQuery. Here's my

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.