我通过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>
答案 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?