What is PJAX and how to detect a PJAX call on the backend?

9

I've been reading some things about PJAX , but it's a bit confusing for its framework-independent operation, I've seen articles but all focused on YUI or plugins for jQuery, .

If I understand the PJAX it is the DOM interaction (via javascript) with the backend through XmlHttpRequest .

What I would like to understand:

  • Should it be used with pushState or is it just a type of implementation?
  • Is it used to load HTML content (did the plugins I tested load the data into a pointed element)?
  • I know I should have to send header through setrequestheader , but I saw two different headers being used, then how to "detect" a PJAX call? (I know that in real it can not differentiate a request XmlHttpRequest from other types of request)
asked by anonymous 02.05.2016 / 01:47

1 answer

3

PJAX is an acronym for PushState Ajax, and is nothing more than a combination of existing methods and technologies:

  • The PushState method belongs to API History of HTML5 and with it you can manage the URL and history stack of a site. ¹
  • AJAX stands for Asynchronous JavaScript and XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with the server-side scripts. ²
  •   

    Should it be used with pushState or is this just a type of implementation?

    Yes, it should be used with PushState. I believe that in this question you got confused with the HTTP protocols Stateless and Stateful. ³

      

    It is used to load HTML content (the plugins I tested   loaded data into a pointed element)?

    It is used to load server content asynchronously using the features of the PushState method for a better front-end experience

      

    I know I have to send header through setrequestheader, but I   I saw two different headers being used, then how to "detect" a   called PJAX? (I know that in the real there is no way to differentiate   XmlHttpRequest request for other request types)

    In methods implemented in most frameworks, it is possible to detect a PJAX call through HEADER X-PJAX

    ¹ Font

    ² Source

    ³ Source

        
    24.05.2016 / 17:28