charlie
charlie

Reputation: 481

PHP include not working in a JQuery .load

I have this code on my index.php page:

require_once 'includes/settings.php';

require_once 'includes/data_functions.php';

if($_GET["section"] == '1') {
    require_once 'includes/includes.php';

    require_once 'pages/'.$_GET["id"].'.php';
    exit();
}

<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
<title>Integra | <?php echo $PageTitle; ?></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

<?php require_once 'includes/includes.php'; ?>

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>

<body class="skin-black-light sidebar-mini sidebar-collapse">

and i use JQuery .load to load pages into a popup div, when loading the page it has the $_GET variable section = 1 so it runs the above code

here is the function that i use to .load pages:

function LoadModal(page, title) {
    title = title || '';

    $( "#modal_page" ).fadeIn("slow");
    $( "#modal_title" ).html(title);

    $("#modal_page_body").html('<h2 align="center">Loading...</h3><p align="center"><i class="fa fa-refresh fa-spin fa-5x"></i></p>'); //$('#LoadingDiv').show();
    $("#modal_page_body").load(page, function(){

    });
    $("html, body").animate({ scrollTop: 0 }, "slow");
}

and then to call this function:

<a href="#" onClick="LoadModal(\'/section/page?seq=add\', \'Add\');" title="Add"><i class="fa fa-plus"></i></a>

so the includes.php file is included in all pages.

this includes some jquery files which have some functions in.

when opening a page in the popup using jquery .load these specific jquery funtcions are not working at all however if i remove the $_GET var (section = 1) to open the page not in the jquery popup (.load) the functions are working fine

what could be causing these to stop working only in the jquery .load

Upvotes: 0

Views: 412

Answers (1)

Quentin
Quentin

Reputation: 943571

Your URL (/section/page?seq=add) doesn't include section=1 in the query string, so $_GET['section'] is not set.

Upvotes: 1

Related Questions