Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pass data via the post method to magnific popup when ajax loading content?

I'm using magnific popup and ajax loading content into it and passing values to the ajax content by appending a query string to the url, which works fine except in IE7 (and probably IE8 as well). The reason is very likely the length of the query string, because it works when I shorten it.

So my question is, is it possible to pass it via some sort of data setting and make it use POST instead of GET. Or does it already use post and I just need to use the right method.

This is what I have:

$.magnificPopup.open({
  tLoading:"",
  modal:false,
  type:'ajax',
  alignTop:true,
  items:{src:urlContainingVeryLongQueryString},
  callbacks:
  {
    ajaxContentAdded:function()
    {
    ...

My test url is 906 characters long in total (well within IE7's 2000ish limit).

like image 384
Graham Avatar asked Dec 19 '22 12:12

Graham


1 Answers

ajax.settings option http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type is passed to jQuery.ajax method http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings , e.g.:

$.magnificPopup.open({

    tLoading:"",
    modal:false,
    type:'ajax',
    alignTop:true,
    items:{src:'http://example.com/ajax'},

    ajax: {
      settings: {
        type: 'POST',
        data: { 
            foo: 'bar'
        }
      }
    }
});
like image 175
Dmitry Semenov Avatar answered Jan 21 '23 17:01

Dmitry Semenov