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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:10:23+00:00 2026-06-11T01:10:23+00:00

Can someone show me a practical example on setting a timeout to my $.ajax

  • 0

Can someone show me a practical example on setting a timeout to my $.ajax request and redo the entire request if the first request is timed out, I’ve read the docs and didn’t get it. I will appreciate any help.

Here is my $.ajax request.

    $.ajax({
        url: '<?php bloginfo('template_directory'); ?>/ajax/product.php',
        type: 'get',
        data: {product_id : product_id},
        beforeSend: function(){
            $('#details').html('<div class="loading"></div>');
        },
        success: function(data){
            $('.iosSlider').fadeOut('fast');
            thisprod.addClass('current');
            $('#details').css({opacity: 0}).html(data).stop().animate({left: 0, opacity: 1}, 800);
        }
    });
    return false;
  • 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-11T01:10:25+00:00Added an answer on June 11, 2026 at 1:10 am

    The ajax function takes a timeout parameter and you can check the status in case of error.

    var call =function(){
        $.ajax({
            url: '<?php bloginfo('template_directory'); ?>/ajax/product.php',
            type: 'get',
            timeout: 400,
            ...
            error: function(x, textStatus, m) {
                if (textStatus=="timeout") {
                     call();
                }
            }
        });
    };
    

    You might want to make something a little smarter to avoid permanent calls…

    From the documentation :

    Set a timeout (in milliseconds) for the request. This will override
    any global timeout set with $.ajaxSetup(). The timeout period starts
    at the point the $.ajax call is made; if several other requests are in
    progress and the browser has no connections available, it is possible
    for a request to time out before it can be sent. In jQuery 1.4.x and
    below, the XMLHttpRequest object will be in an invalid state if the
    request times out; accessing any object members may throw an
    exception. In Firefox 3.0+ only, script and JSONP requests cannot be
    cancelled by a timeout; the script will run even if it arrives after
    the timeout period.

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

Sidebar

Related Questions

Given the example below, can someone please show me how this could be called?
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
Can someone show an example of how to create multiple view change events in
Can someone show/point/help me to a resource for distributed development Git example or guide?
Can someone show me a working example of how to generate a SHA hash
Can someone show me an example how to use getopts properly or any other
Can someone show me an example how to properly use the getRelativeDateTimeString() that is
To give an example of the kind of request that I can't figure out
Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this
Can someone show me how to print the ListView contents with the ColumnHeaders, without

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.