0

I'm having a problem with .load's function.

When I'm loading a file dynamically with jQuery the file being inserted into my PHP file isn't effected by my file called master.php. Master.php has all the functions that are necessary to process everything within that file that is being loaded dynamically in jQuery's .load function.

So, is there a way to have it loaded? I can't just have master.php in that file, because my file that's being loaded with the .load function is already in same file that it's being called again with .load.

Original file code:

<?php 
     include 'include/master.php';
?>
<div id='loadingDock'>
    <?php
         include 'include/sequence.php'; 
    ?>
</div>

But then after I dynamically add something into the database, I want to load sequence.php again to show the results.

    $(document).ready(function(){
        $("#hoverElement").click(function(){
             $("#loadingDock").load('include/sequence.php');
        });
    });

Any thoughts?

1
  • Need some code samples to see what you're doing, how you're trying to call .load(), etc. Are you trying to reload sections of your Master.php file into your current file? Can't tell from just your description so far. Commented Oct 25, 2012 at 15:14

2 Answers 2

1

You need to separate out the functions that are shared between master.php and sequence.php, and include just those in both files.

For example:

// Master.php
<?php 
    include_once('common.php');

    // ... Do things you don't want in sequence.php
?>

// Sequence.php
<?php
    include_once('common.php');

    // ... Do things you don't want in master.php
?>

// Any other files that need common functions
<?php
    include_once('common.php');

    // ... Do things
?>

// Common.php
<?php
    // Shared functions
?>
Sign up to request clarification or add additional context in comments.

2 Comments

The problem though is that it won't just be between the two. Those functions might be used elsewhere.
OK, so you can include common.php in every file (see edited code)
1

pass a parameter in the call load

$(document).ready(function(){
    $("#hoverElement").click(function(){
         $("#loadingDock").load('include/sequence.php',{a:1});
    });
});

beginning of the file file sequence.php

<?
if(isset($_POST["a"])){
    include 'master.php';
}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.