So I'm having a huge brain fart here and I know for a fact I am going about this the wrong way. Unfortunately, I can't refer to previous work I've done where I have done this correctly as I no longer have access to them.

I have my index page grabbing information from different PHP pages then displaying them on screen. The reason why it's grabbing them from different PHP pages is because some times, these scripts will fail. If this was all in the same page, it would cause the whole page to fail so I want to call each bit individually so if one fails, it doesn't cause the whole thing to fall over, only that part fails. This works with both object and iframe like so:

<object data="./include.php" type="text/html">
    <p>There was a problem loading the record.</p>
</object>

<iframe src="./include.php">
    <p>There was a problem loading the record.</p>
</iframe>

While this does work, the problem is that neither iframe nor object has a dynamic height. Using PHP include or require will display the content at an effective dynamic height but the problem there is that with require, if the included file fails the whole page fails and with include, if there's an error then the rest of the page will stop loading.

The ideal solution (which I think would be using JSON?) would work similar to include but load it asynchronously and if it returns an error (500 or otherwise) display a friendly message like above. The height needs to be dynamic so that it doesn't have its own scrollbar. I only want the scrollbar of the main page.

Member Avatar for diafol

Have you investigated why your scripts fail? Unsure why you.re loading stuff into an object or iframe.

I'm currently using JQuery but my client doesn't want any JQuery or Javascript on the site which is a pain.

In regards to the scripts failing, they sometimes fail due to the information being generated on the pages taking too long. It's not common for it to fail and I don't have the necessary permissions to try to fix that problem myself.

In case anyone comes accross this trying to find out how to do this using JQuery, the JQuery I am using (which does work) is:

<script type="text/javascript">
    $(document).ready(function() {$('#insert-file').load('./test.php');});
</script>

And the associated HTML:

<div id="insert-file"></div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.