willin / InstantPjax

A jQuery Plugin for PJAX with instantclick.
MIT License
12 stars 0 forks source link

Form Support #1

Open schester44 opened 8 years ago

schester44 commented 8 years ago

Does this support PJAX form submits? The code works well out of the box but I can't seem to get forms to work. With the original PJAX library, you would submit a form using data-pjax="true", i've tried changing it to data-ipjax="true" and have also tried changing $_SERVER['HTTP_X_PJAX'] to 'HTTP_X_IPJAX'.

Wondering if there is any official support or a work around?

Thank you for your hard work!

willin commented 8 years ago

try this:

$('#form').submit(function(e){
  e.preventDefault();
  $.ipjax({
        url: $('#form').attr('action')+'?ipjax=true',
        container: '#main',
        timeout: 10000, //ms
        show: function(data,callback,isCached){
                 // handle result
        },
        type:'POST',
        dataType: 'json',
        data: $('#form').serialized()
    });
});