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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:09:27+00:00 2026-06-13T15:09:27+00:00

I have a jQuery script running that makes a periodic AJAX call using the

  • 0

I have a jQuery script running that makes a periodic AJAX call using the following code.

var a = moment();
var dayOfMonth = a.format("MMM Do");
var timeSubmitted = a.format("h:mm a");
var count_cases = -1;
var count_claimed = -1;

setInterval(function(){
    //check if new lead was added to the db
    $.ajax({
        type : "POST",
        url : "inc/new_lead_alerts_process.php",
        dataType: 'json',
        cache: false,
        success : function(response){

            $.getJSON("inc/new_lead_alerts_process.php", function(data) {

                if (count_cases != -1 && count_cases != data.count) {
                    window.location = "new_lead_alerts.php?id="+data.id;
                }
            count_cases = data.count;
            });
        }
    });

This is the PHP that runs with each call:

$count = mysql_fetch_array(mysql_query("SELECT count(*) as count FROM leads"));
$client_id = mysql_fetch_array(mysql_query("SELECT id, client_id FROM leads ORDER BY id DESC LIMIT 1"));

echo json_encode(array("count" => $count['count'], "id" => $client_id['id'], "client_id" => $client_id['client_id']));

I need to change the code so that the alert only triggers when a new entry is added to the database, not when an existing entry is removed. As it stands, the alert fires on both events.

Any help is greatly appreciated.

  • 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-13T15:09:28+00:00Added an answer on June 13, 2026 at 3:09 pm

    The solution was very simple. I changed count_cases != data.count to count_cases < data.count. That was all there was to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have a script that loads in a div with images running jQuery Cycle
I have the following jQuery function that I'm using to display a timer on
I have a jquery script that attaches a click event to every link, running
I have a jQuery script running on an ASP site that shows hidden DIVs
I have two scripts running on the same page, one is the jQuery.hSlides.js script
I have a jQuery script that polls my server for new data, but it
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });

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.