jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

$.pjax doesn't work, but $.pjax.submit does

Open alonewarrior opened this issue 11 years ago • 5 comments

I have been attempting to get PJAX to work on my site for awhile now. It succeeded for awhile last night, but suddenly it no longer wishes to work properly. Even when I adjust the timeout, 2 requests still occur, with the latter not containing the appropriate X-PJAX information and causing a full page reload.

This is what I'm using to call PJAX:

$(function(){
    $(document).pjax('a.pjax', '#test', { fragment: ('#test'), timeout: 10000 });
});

On the other hand, the form portion works perfectly fine, and I haven't had any issues yet today.

I am at a loss of what to do right now; I'm going insane!

alonewarrior avatar Dec 30 '13 02:12 alonewarrior

So I've toyed around with the timeout and adding the fragment, which has suddenly allowed me to do PJAX in restricted scenarios, but not in the ones that I would prefer. By this, I mean that I can leave a "Go back" link after submitting a form, and that link will be accepted without reloading the page. But if I try to use a link that's hard-coded on the page, it will not work, and instead will fire twice.

alonewarrior avatar Dec 30 '13 06:12 alonewarrior

I had the same problem, but then I realized that the Readme says to check for "X-PJAX", when it actually is "x-pjax". Hopefully this helps.

TrevTwells avatar Jan 17 '14 15:01 TrevTwells

$.pjax doesn't work for me either. It seems very inconsistent, sometimes it works, other times it doesn't.

marcusds avatar Apr 25 '14 00:04 marcusds

^ I'm finding this as well. It'll work one day then the next it's broken, it seems fickle.

kirkbushell avatar Jan 09 '15 17:01 kirkbushell

Sorry that all of you have troubles with pjax. The behavior of pjax varies pretty wildly with what sort of response it gets from the server. For example, the original poster defined the fragment: "#test" option which means that the element with ID "test" will be extracted as pjax content from the server response. If that element doesn't exist, however, the page will be force-reloaded.

So when you're reporting a pjax bug, please include the full code of how you set up pjax on your site (like the original poster), what was the behavior that you expected, what is the exact behavior that you got, and the raw HTML response from the server for the pjax request. Thanks!

mislav avatar Feb 05 '15 22:02 mislav