I’m trying to get off site content and display it on my web site.
I have site 1 and I want to display some content from site 2 on site 1.
My plan is to use AJAX, on site 1, to load a PHP script, on site 1, that will load the content from site 2 and echo it. Then AJAX would take the echo from the PHP script and display it in a DIV on site 1.
My question is…
Will all the other static content of site 1 wait for the PHP script to fully load and echo it’s content before it loads?
OR
Will all the other static content of site 1 load initially, then when the PHP script is finished getting the content from site 2 AJAX will display it in the DIV?
This will all happen on page load.
If you do it on Page Load, your DOM will render first before displaying the AJAX loaded content. Page_Load means that the function will wait until.. well… the page is loaded.
If you didn’t want this to happen you could have the script running AS part of the Page Load, with inline Javascript.
Say your function was in your
<head>section.Then at the start of your
<body>section, you could call that function.This might not be good practice however, since the other website might not be available, and may cause your entire page to time out or annoy the user because your website is taking longer to load.
It’s pretty common practise to load AJAX, AFTER your page is loaded, so I would go with option #1.