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 6474435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:35:12+00:00 2026-05-25T06:35:12+00:00

Hi all I have a (probably) simple problem but I just can’t figure out

  • 0

Hi all I have a (probably) simple problem but I just can’t figure out why it’s not working.

The code below should be fairly easy to follow:

<?php
require('../db.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"> 
<html lang="en"> 
<head> 

<meta http-equiv="content-type" content="text/html; charset=utf-8"> 
<title>Website Checker</title> 

<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.simpletip-1.3.1.js"></script> 
<script type="text/javascript">
$(document).ready(function() {

$('#check').click(function(){

$('.http-status').html('<img src="images/spinner.gif"/>').fadeOut('slow').fadeIn('slow');

$('#site-list li.websites').each(function()
{
    //var newurl = $(this).find('span.url a').attr('href');
    var newurl = $(this).find('span.url').html();
    $.ajax(
    {
        type:    "POST",
        url:     "process.php",
        data:    ({"a":newurl}),
        cache:   false,
        success: function(message)
        {
            $(this).find('span.http-status').html(message);
        } //End AJAX return
    }); //End AJAX call
    }); //End li each
}); //End Check

$('#check').click();

});

</script>

<ul id="site-list" class="list"> 
<li class="title">
    <span class="id"></span>
    <span class="name">Title</span>
    <span class="url">URL</span>
    <span class="status">HTTP Status</span>
</li> 
<?php
// some PHP to fetch all the gig entries from the shows table
$sql = "SELECT * FROM `check`";
$query = mysql_query($sql) or die(mysql_error());
// a loop to place all the values in the appropriate table cells
while ($row = mysql_fetch_array($query)){
//begin the loop...
$id=$row['id'];
$name=$row['name'];
$url=$row['url'];
?>
<li class="websites">
    <span class="id"><?php echo $id; ?></span>
    <span class="name"><?php echo $name; ?></span> 
    <span class="url"><?php echo $url; ?></span>
    <span class="status http-status"></span>
</li>

<?php
}
?>
</ul>
<br /> 
<a href="#" id="check" class="button">Check Now</a>

This basically pulls site data from a db and presents it to the user and what I am trying to do is when you click the button for the http code of each site to be checked and displayed (and also run upon the page first being loaded)

This seems to work fine – the correct data is sent and recieved but then after that the spinner is STILL there!

link: http://www.4playtheband.co.uk/check/

process.php (if it helps):

<?php
require('../db.php');

$url= NULL;
if(isset($_POST['a'])) {    $url = mysql_real_escape_string($_POST['a']);   }

function Visit($url)
{
$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";$ch=curl_init();
curl_setopt ($ch, CURLOPT_URL,$url );
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch,CURLOPT_VERBOSE,false);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$page=curl_exec($ch);

//echo curl_error($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if($httpcode>=200 && $httpcode<300) 
{
    echo '<span class="up">'.$httpcode.'<span class="icon"><img src="images/info.png" alt="website is up"/></span></span>'; exit;
}
else
{
    $httpcode=404;

    $date = date("l, j \of F Y \@ H:i");

    $to      = "someone@domain.com";
    $subject = "Urgent: $url is down";
    $message = "Hello,\n\nIt appears that on our latest check of $url on $date that the site was down.\n\nRegards,\nWeb Checker";
    $headers = 'From: noreply@webchecker.co.uk' . "\r\n" .
           'Reply-To: noreply@webchecker.co.uk' . "\r\n";

    mail($to, $subject, $message, $headers);
    echo '<span class="down">'.$httpcode.'<span class="icon"><img src="images/info.png" alt="website is down"/></span></span>'; exit;
}
}

if(!empty($url)){ Visit($url); exit; } 

?>
  • 1 1 Answer
  • 3 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-05-25T06:35:13+00:00Added an answer on May 25, 2026 at 6:35 am

    You should refer to .http-status element within each li in the success callback. Since you are making ajax calls in a loop we need to store each li object into local variable and create a closure by calling a method which will set the status message. Try this

    $('#check').click(function(){
    
    $('.http-status').html('<img src="images/spinner.gif"/>').fadeOut('slow').fadeIn('slow');
    
    
    $('#site-list li.websites').each(function()
    {
        var $li = $(this);
    
        //var newurl = $(this).find('span.url a').attr('href');
        var newurl = $(this).find('span.url').html();
        $.ajax(
        {
            type:    "POST",
            url:     "process.php",
            data:    ({"a":newurl}),
            cache:   false,
            success: function(message)
            {
                setStatusMessage(message, $li);
    
            } //End AJAX return
        }); //End AJAX call
        }); //End li each
    }); //End Check
    
       function setStatusMessage(message, li){
           li.find('.http-status').html(message);
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably simple question and I'm just missing something, but I'm stuck out of ideas.
There is probably a simple answer to this question but I do not have
I have code that all over the place(probably 20-30 instances) does this: <widget>.setVisible((condition ==
I'm a newbie with WPF and c# and have a (probably very simple) problem.
all. This question probably has a devilishly simple answer but it has kept me
Hey guys I know that this is probably just a simple sql statement but
I am maintaining several Perl scripts that all have similar code blocks for different
There is probably a really simple answer for this ... I have a project
This is probably a simple one, but I've tried loads of different things and
I have three classes that all have a static function called 'create'. I would

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.