Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:19:42+00:00 2026-06-02T14:19:42+00:00

I have a PHP script (pasted below) which pulls in meta data from a

  • 0

I have a PHP script (pasted below) which pulls in meta data from a list of URL’s, the problem is it can take a while to load and the user never knows when it’s completely finished (unless they keep an eye on the loading icon in their broswer tab)

I’ve been looking around online for a long time but cannot find a solution to this, I’ve read I can use Ajax but how exactly could I use it on this script?

Thanks for the help!

<script type="text/javascript">
function showContent(vThis)
{
    // http://www.javascriptjunkie.com
    // alert(vSibling.className + " " + vDef_Key);
    vParent = vThis.parentNode;
    vSibling = vParent.nextSibling;
    while (vSibling.nodeType==3) { // Fix for Mozilla/FireFox Empty Space becomes a TextNode or         Something
        vSibling = vSibling.nextSibling;
    };
    if(vSibling.style.display == "none")
    {
        vThis.src="collapse.gif";
        vThis.alt = "Hide Div";
        vSibling.style.display = "block";
    } else {
        vSibling.style.display = "none";
        vThis.src="expand.gif";
        vThis.alt = "Show Div";
    }
    return;
}

</script>



<form method="POST" action=<?php echo "'".$_SERVER['PHP_SELF']."'";?> >
<textarea name="siteurl" rows="10" cols="50">
<?php //Check if the form has already been submitted and if this is the case, display the   submitted content. If not, display 'http://'.
echo (isset($_POST['siteurl']))?htmlspecialchars($_POST['siteurl']):"http://";?>
</textarea><br>
<input type="submit" value="Submit">
</form>
</div>

<div id="nofloat"></div>
<div style="margin-top:5px;">
<h4><img src="expand.gif" alt="Show Div" border="0" style="margin-right:6px; margin-  top:3px; margin-bottom:-3px; cursor:pointer;" onclick="showContent(this);" />Show me the    script working!</h4>
<div style="margin-top:5px; display:none;">
<table class="metadata" id="metatable_1">
<?php
ini_set('display_errors', 0);
ini_set( 'default_charset', 'UTF-8' );
error_reporting(E_ALL);
//ini_set( "display_errors", 0);
function parseUrl($url){
    //Trim whitespace of the url to ensure proper checking.
    $url = trim($url);
    //Check if a protocol is specified at the beginning of the url. If it's not,     prepend 'http://'.
    if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
            $url = "http://" . $url;
    }
    //Check if '/' is present at the end of the url. If not, append '/'.
    if (substr($url, -1)!=="/"){
            $url .= "/";
    }
    //Return the processed url.
    return $url;
}
//If the form was submitted
if(isset($_POST['siteurl'])){
    //Put every new line as a new entry in the array
    $urls = explode("\n",trim($_POST["siteurl"]));
    //Iterate through urls
    foreach ($urls as $url) {
            //Parse the url to add 'http://' at the beginning or '/' at the end if not   already there, to avoid errors with the get_meta_tags function
            $url = parseUrl($url);
            //Get the meta data for each url
            $tags = get_meta_tags($url);
            //Check to see if the description tag was present and adjust output    accordingly
            $tags = NULL;
$tags = get_meta_tags($url);
if($tags)
echo "<tr><td>$url</td><td>" .$tags['description']. "</td></tr>";
else 
echo "<tr><td>$url</td><td>No Meta Description</td></tr>";
    }
}
?>
</table>
</div>
<script type="text/javascript">
        var exportTable1=new ExportHTMLTable('metatable_1');
    </script>
<div>
        <input type="button" onclick="exportTable1.exportToCSV()"   value="Export to CSV"/>
        <input type="button" onclick="exportTable1.exportToXML()"   value="Export to XML"/>
    </div>
</div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:19:48+00:00Added an answer on June 2, 2026 at 2:19 pm

    Idea:

    Add php code to different file

    Show the loading image

    And then call this function

    function Load()
    {
        var xmlhttp;
        var url;
    
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {           
                //(optional)do something with response: xmlhttp.responseText
                document.getElementById("area").innerHTML=xmlhttp.responseText;
                document.getElementById("loadingimage").src = "afterloading.gif";
            }
        }
    
        xmlhttp.open("GET","phpfile.php",true);
        xmlhttp.send();
    }
    

    this function goes to your javascript place then either call it with jquery after document finishes loading or

    <body onload="Load()">
    

    and in body place something like

    <img id="loadingimage" src="loading.gif"/>
    <div id="area">...</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script (pasted below) that pulls in the meta descriptions from a
I have a CSV export script (enrdata_arch.php) which calls information from an existing database
I have a pagination script which I have posted below, the problem is I
I have a PHP script (news-generator.php) which, when I include it, grabs a bunch
I have this script below which i found on SO to generate pagination and
I have the following script to take an uploaded PDF in PHP and call
I have php script that creates a temporary watermark image for users that are
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have a PHP script running on XAMPP in Windows XP that will open
I have a php script that backup my table in .sql format and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.