Giter Club home page Giter Club logo

Comments (14)

defunkt avatar defunkt commented on May 22, 2024 4

You can now change the timeout globally:

$.pjax.defaults.timeout = 5000

from jquery-pjax.

slampis avatar slampis commented on May 22, 2024 2

I guess I figured it out. It was caused by the default timeout in the PJAX requests which was to short for me.

from jquery-pjax.

tommoor avatar tommoor commented on May 22, 2024

Glad you figured this one out... been banging my head against it all morning trying to figure out why sometimes pjax was working and not others.

This is a particular issue for me with rails in development mode as the timeout is often exceeded.

from jquery-pjax.

airstrike avatar airstrike commented on May 22, 2024

Thank you for this! I was experiencing the same problem. Perhaps a bigger default value is in order?

Cheers,
AT

from jquery-pjax.

rdewell avatar rdewell commented on May 22, 2024

I'm also seeing many aborted calls. My app responds in < 1 second, but just to try I increased the timeout to 30000. No luck.

Often I'll see 3 aborted calls to the URL, and then a final successful call to the URL.

Any other things to look into?

from jquery-pjax.

dsabanin avatar dsabanin commented on May 22, 2024

I'm seeing the same thing as rdewell. Even if pjax request is under timeout, I see that JS triggers many unnecessary requests to the same URL and only one of them is finished - others are aborted before they proceed. See the screenshot below:

screenshot

from jquery-pjax.

karlentwistle avatar karlentwistle commented on May 22, 2024

Thanks, I was having this issue as well, using defaults.timeout = 5000 worked.

from jquery-pjax.

jlovison avatar jlovison commented on May 22, 2024

Just for posterity's sake -- I had been running into this problem, and was tearing my hair out.

I finally realized that I was calling the $.fn.pjax() function in my returned pjax templates with the intention of binding to newly loaded elements.

Apparently that was unnecessary, and I was instead generating multiple requests bound to the handler, and those requests returned xhr.readyState = 1, leading to aborted requests.

This was compounded when I prevented the timeout, as the number of canceled requests continued to linearly grow and a new page load was never generated.

So for anyone that stumbles across this in the future, and extending the timeout still results in aborted requests (such as @rdewell and @dsabanin above), make sure you aren't binding extra events to your handlers.

(Note: It might be useful if the docs indicated the $.fn.pjax() binds to returned content, and calling again is unnecessary.)

from jquery-pjax.

rafaeldotjs avatar rafaeldotjs commented on May 22, 2024

Perfect. Thank you for the help, this solved my problem.

from jquery-pjax.

BennyH26 avatar BennyH26 commented on May 22, 2024

@kromem Thanks so much, you really saved me on this. I was struggling with this problem for AN ENTIRE DAY.

from jquery-pjax.

HelloLyfing avatar HelloLyfing commented on May 22, 2024

You can now change the timeout globally:
$.pjax.defaults.timeout = 5000

Works for me ! Thks !

from jquery-pjax.

FrankFan avatar FrankFan commented on May 22, 2024

I was experiencing the same problem.
but $.pjax.defaults.timeout = 5000 I've tried to use this line of code, still didn't work.

My situation is:

  1. I use jstree with pjax to load file
  2. when I first time to click, there was 2 requests, and the first one was canceled,
  3. when I second time to click, there was 3 requests, the first and the second request was canceled too
  4. the same way, when I thrid time to click, there was 4 requests, and the first 3 request was canceled too.

My Opioion:
fist I thouth it maybe something wrong with my event bind multiple times, and I use jqury.off('click),
the problem still exists.

Anyone can help me analysis what's wrong with my code ?

code:

$jstree.on("select_node.jstree", function(e, data) {
        if (data && data.node && data.node.data == 'tree') {
                  // do normal ajax request
        } else { // blob 
                // pjax here
                $(document).pjax('nav a.jstree-clicked', '#tree-content-holder', {fragment:'#tree-content-holder', timeout:9000});
       }
});

from jquery-pjax.

razamehdi-vteams avatar razamehdi-vteams commented on May 22, 2024

@defunkt can you just give an example on how to set options for a pjax request. i understand we can set it like this:

$.pjax.defaults.timeout = 5000

but how can we set in this?

$(document).pjax('a#contentlink','#pjax-container');

from jquery-pjax.

mislav avatar mislav commented on May 22, 2024

@razamehdi-vteams See README:

$(document).pjax('a#contentlink', {
  timeout: 5000,
  container: '#pjax-container'
})

from jquery-pjax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.