Comments (14)
You can now change the timeout globally:
$.pjax.defaults.timeout = 5000
from jquery-pjax.
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.
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.
Thank you for this! I was experiencing the same problem. Perhaps a bigger default value is in order?
Cheers,
AT
from jquery-pjax.
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.
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:
from jquery-pjax.
Thanks, I was having this issue as well, using defaults.timeout = 5000 worked.
from jquery-pjax.
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.
Perfect. Thank you for the help, this solved my problem.
from jquery-pjax.
@kromem Thanks so much, you really saved me on this. I was struggling with this problem for AN ENTIRE DAY.
from jquery-pjax.
You can now change the timeout globally:
$.pjax.defaults.timeout = 5000
Works for me ! Thks !
from jquery-pjax.
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:
- I use jstree with pjax to load file
- when I first time to click, there was 2 requests, and the first one was canceled,
- when I second time to click, there was 3 requests, the first and the second request was canceled too
- 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.
@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.
$(document).pjax('a#contentlink', {
timeout: 5000,
container: '#pjax-container'
})
from jquery-pjax.
Related Issues (20)
- Multiple fragment processed
- Document links dump bytes in dom
- the current node list is empty
- PJAX memory Leak issue HOT 1
- Link to do just as browser back button HOT 2
- Prevent form submit with pjax when "enter" is clicked in a form element
- In the JavaScript code, Chinese is converted to unicode.
- the documented `ready pjax:end` does not work with Jquery 3.4.1 or 2.2.4 HOT 5
- How to cancel/abort ongoing request?
- Can't run a container cleanup before the cache snapshot
- When using Pjax, the target page is returned without replace the container
- Modal bootstrap is create class modal-backdrop two times when using pjax
- skeleton loading
- Unusual reaction with pjax (Content is duplciating) HOT 1
- New generation Pjax variations HOT 3
- Pjax switch fail: DOM doesn't look the same on new page
- The css class is missed,when i use PJAX,How to reload it?
- Wrong events lifecycle in case when ajax request is not async
- page reload after append link to hmtl
- 给a标签同时添加多个点击事件不生效
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-pjax.