Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pjax request change status to canceled as soon as it fires

here is my code

$(document).on('click', '#global-search-button', function() {


    $.pjax({
        url: "http://localhost/project/brows",
        container: '#pjax-container',
        timeout: 9000000 ,
    })

});

when i click on the button

enter image description here

her here is more info on request

Request URL: http://localhost/project/brows?_pjax=%23pjax-container
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: text/html, */*; q=0.01
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost/project/brows
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
X-PJAX: true
X-PJAX-Container: #pjax-container
X-Requested-With: XMLHttpRequest
_pjax: #pjax-container

i have to add some more info to be able to post the question , so here it is

like image 404
hretic Avatar asked Mar 17 '19 18:03

hretic


2 Answers

Often I had a similar problem because I included the hostname as well.

Try calling pjax without it like so

$.pjax({
  url: "/project/brows",
  container: '#pjax-container',
  timeout: 9000000,
})
like image 50
lumio Avatar answered Oct 19 '22 14:10

lumio


the reason was very simple and odd , basically if the href of the link should be a # it would cancel as soon as it fires .... i changed it to javascript:void(0) and it worked

like image 2
hretic Avatar answered Oct 19 '22 16:10

hretic