0

I got load content via eModal and i got url with id`s example: #index.php?id=1&idt=2 How can in ajax load content of modal use this parameters id and idt ?

<script>
$(document).ready(function () {/* activate scroll spy menu */

    var iconPrefix = '.fa-';


    $(iconPrefix + 'mixcloud').click(ajaxDemo);
    ///////////////////* Implementation *///////////////////

    // Demos
    function ajaxDemo() {
        var title = 'Znaczniki H1';
        var params = {
            buttons: [
               { text: 'Close', close: true, style: 'danger' },
               { text: 'New content', close: false, style: 'success', click: ajaxDemo }
            ],
            size: eModal.size.lg,
            title: title,
            url: 'views/h1.php'
        };

        return eModal
            .ajax(params)
            .then(function () { alert('Ajax Request complete!!!!', title) });
    }
  });
  </script>

1 Answers1

1

Ok if you want to obtain the GET Param id of the actual page you're in.

var url_string = "http://www.example.com/index.html?id=joe";
var url = new URL(url_string);
var id = url.searchParams.get("id");


I took this function from this post: How to get the value from the GET parameters?

amenzou
  • 319
  • 1
  • 7
  • I wanna load content from h1.php but inside this h1.php is function wich need atribute from url – CommanderSpock Aug 06 '17 at 18:21
  • example: i am on webside #index.php?id=1&idt=2 and there is modal where ajax load inside h1.php and there is function wich need id from url – CommanderSpock Aug 06 '17 at 18:22
  • Ok I edited my answer to better fit your question I hope. – amenzou Aug 06 '17 at 18:56
  • i dont know why not get id or idt to url var iconPrefix = '.fa-'; var id = $(this).attr('id'); var idt = $(this).attr('idt'); $(iconPrefix + 'mixcloud').click(ajaxDemo); function ajaxDemo() { var title = 'Znaczniki H1'; var params = { ], size: eModal.size.lg, title: title, url: 'views/h1.php?id='+id+'&idt='+idt, }; return eModal .ajax(params) .then(function () { alert('Ajax Request complete!!!!', title) }); – CommanderSpock Aug 06 '17 at 19:29
  • I just want to clarify something. The `id` and `idt` values are attributes of the Dom element(the icon) or GET Param of the actual page Uri? – amenzou Aug 06 '17 at 21:07
  • GET Param of the actual page Uri – CommanderSpock Aug 07 '17 at 07:40