$ _GET在AJAX变量模态引导程序中

时间:2017-08-06 16:14:15

标签: php ajax

我通过eModal获得了加载内容,我得到了ID为例的URL:#index.php?id = 1& idt = 2 如何在ajax中加载模态的内容使用这个参数id和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 个答案:

答案 0 :(得分:1)

好的,如果你想获得你所在的实际页面的GET参数id

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


我从这篇文章中获取了这个功能:How to get the value from the GET parameters?