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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:45:48+00:00 2026-05-16T11:45:48+00:00

For example I have general code for catching json, that says – its error

  • 0

For example I have general code for catching json, that says – “its error request”. This code is in ajaxComplete, how can I stop executing specific code from ajaxComplete point?

$.post('url', params, 
    function(json){
        if (json.success == false){
             alert('error')
        }
        if (json.success == true){
             alert('success')
        }
    }, 'json'
);

Instead of this code in each ajax request, I want to use something like:

$().ajaxComplete(function(e, xhr){
        if (json.success == false){
             stop_execution_of_post()
        }
        if (json.success == true){
             proceed_execution_of_post();
        }
}

Than in post, you would only to write this:

$.post('url', params, 
    function(json){
        alert('success')
    }, 'json'
);

Is that possible to STOP from execution SPECIFIC ajax function?

  • 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-16T11:45:48+00:00Added an answer on May 16, 2026 at 11:45 am

    Instead of using ajaxComplete you can override an internal method of jQuery. Obviously you need to be careful because the internal method may change. This is written against jQuery 1.4.

    The method is jQuery’s httpSuccess(xhr). This takes an XMLHTTPRequest object. When it returns false jQuery’s AJAX error handler is called (handleError). Most notably the success handler is not called. Note that the complete handler is always called.

    An example:

    // Remember the old function
    var oldhttpSuccess = jQuery.httpSuccess
    
    // Create the override
    jQuery.httpSuccess = function (xhr) {
        // Record the result from the old function
        var success = oldhttpSuccess(xhr)
        // If that's bad return 
        if (!success) {
            return success
        }
    
        // Do our custom test
        if (weNeedToStop) {
           return false
        }
    
        // Return the "inherited" success value
        return success
    }
    

    So whenever our weNeedToStop test is true, for any ajax response, the success handler is not called.

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

Sidebar

Related Questions

I'd like my dictionary to be case insensitive. I have this example code: text
I have this modified code example I took from the wikipedia article on anonymous
I have a general OO design question that stems from a Hibernate Model. Example
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example: I have an class that inherits from UIImageView. An object creates an instance
Example: I have a selector like this, which I give to another method as
Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I
I have this code: cursor.execute( ''' SELECT id,DISTINCT tag FROM userurltag ''') tags =
Hallo, i have following line of code: InputStream passoloExportFileInputStream = getClass().getClassLoader().getResourceAsStream(/com/thinkplexx/lang/de/general.xml); and i know
I just have a few general questions about keeping code clean and readable. 1)

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.