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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:22:38+00:00 2026-05-20T10:22:38+00:00

I have something like this $.ajaxSetup({ cache: false }); I am wonder can you

  • 0

I have something like this

 $.ajaxSetup({
        cache: false
    });

I am wonder can you do ajaxSetup like you can do $.ajax

var jqxhr = $.ajax({ url: "example.php" })
    .success(function() { alert("success"); })
    .error(function() { alert("error"); })
    .complete(function() { alert("complete"); });

So could I do

 var a =    $.ajaxSetup({
            cache: false
        })

then

a.success(function() { alert("success"); })

I have not had a chance to try to this out yet. Once I have few minutes I going to try this but if someone knows that would be good too. I also don’t see anything in the documentation.

  • 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-20T10:22:39+00:00Added an answer on May 20, 2026 at 10:22 am

    AFAIK, no you won’t be able to do that – .ajaxSetup() isn’t a defered object, unlike .ajax() as of jQuery v1.5. So you will just get an error saying the object doesn’t have the methods.

    If what you are trying to do is setup things to happen with every .ajax() call (.ajaxSetup() sets up defaults for all .ajax() calls). You can access global ajax callbacks like:

  2. $.ajaxComplete(function(){alert("complete");})
  3. $.ajaxError(function(){alert("error");})
  4. $.ajaxSuccess(function(){alert("success");})
  5. if you want to perform actions on ALL ajax calls if that is what you are aiming for? You will also have access to all the callback parameters:

    .ajaxError(event, XMLHttpRequest, ajaxOptions, thrownError)


    Updates to follow up comments:

    As per the docs for .ajaxSetup():

    Note: Global callback functions should
    be set with their respective global
    Ajax event handler
    methods: .ajaxStart(), .ajaxStop(),
    .ajaxComplete(), .ajaxError(),
    .ajaxSuccess(), .ajaxSend() rather
    than within the options object for
    $.ajaxSetup()

    So it looks like there is no global handler for the statusCode like the callback added in 1.5. However again as per the docs:

    If the request is successful, the
    status code functions take the same
    parameters as the success callback; if
    it results in an error, they take the
    same parameters as the error callback.

    So I would think, you could use for example:

    $('body').ajaxSuccess(function(e, xhr, settings) {
        if (xhr.status == "200")
            alert("Your call to: '"+settings.url+"' was a success (status code: "+xhr.status+")");
    });
    
    $('body').ajaxError(function(e, xhr, settings) {
        if (xhr.status == "401")
            alert("You are not logged into the remote page!");
        if (xhr.status == "404")
            alert("The remote page could not be found: '"+settings.url+"'(status code: "+xhr.status+")");
    });
    

    Take a look at the demo here it shows a successful and an un-successful .ajax() call – showing local and global actions, including dealing with different statusCodes.

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

Sidebar

Related Questions

So I have something like this: var xmlStatement:String = xmlObject.node[3].@thisValue; What mystery function do
Sounds like a weird question, but say I have something like this: $.post( /myajax.php,
I have something like this: barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); Now, how
I have something like this: <node TEXT= txt A /> <node TEXT= txt X
I have something like this: <div class=content> <a href=#>A</a> </div> <div class=content> <a href=#>B</a>
It is typical to have something like this in your cshrc file for setting
Supposing to have something like this: #include <map> int main(){ std::map<int,int> m; m[1] =
In our code we used to have something like this: *(controller->bigstruct) = ( struct
I am writing an XML document in C#. I have something like this... string
In a bunch o' places in my code, I have something like this: public

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.