Nealv
Nealv

Reputation: 6884

PJAX refreshes page

I am using drupal with PJAX.

As soon as I call a page trough PJAX, my browser redirects. It happens on this line in jquery.pjax:

var xhr = pjax.xhr = $.ajax(options)

I don't know how to find the problem, can anyone help me out ? If you need additional info please tell me.

Upvotes: 1

Views: 216

Answers (1)

Fonzy
Fonzy

Reputation: 691

I don't think you are looking in the right place!

The php page that you call via pjax has to have an if statement with the selected element in it, otherwise a pjax call will be ignored and the page will refresh.

Called Page:

<?php $headers = getallheaders();
if($headers['X-PJAX'] == 'true'):
?> <ul id='pjax-stuff'>
// Stuff you called with pjax
</ul> 
<?php 
else: ?>
// Stuff if pjax times out
<?php endif ?>

JavaScript File:

$(document).pjax('nav a', '#pjax-stuff', { fragment: '#pjax-stuff' });

I didn't test this, but it should give you an idea! Hope that helps, cheers!

Upvotes: 1

Related Questions