I use PJAX and it works great for simple examples, but I need to do some advanced tasks with PJAX requests.
- I would like to add some data to every PJAX request. The data I want to add is actually an array of objects. See the example below.
- I may need to use POST instead of GET to call ajax.
- I may need to change the content type to "application / json".
I have the following ...
var people = [{ first: "John", last: "Doe" }, { first: "Jane", last: "Smith" }]; $("a.sheet-link").pjax("#content"); $('#content').on('pjax:beforeSend', function (e, jqXHR, settings) {
I tried various approaches ...
- using jQuery.ajaxSetup to set some default values ββ(I can set the data, but then the _pjax data item was not added, I tried to set the POST type, but it wasnβt.)
- trying to change jqXHR object in beforeSend handler
- trying to change the settings object in the beforeSend handler
All attempts give me various problems.
I'm not sure why this is so complicated. Any help would be greatly appreciated!
ajax pjax
Kevin
source share