Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Can anyone tell me please why the alert(you have a callback) wont fire??

  1. #1
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can anyone tell me please why the alert(you have a callback) wont fire??

    Code:
    <?php
    include("AgentLockout.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Agent-Homepage</title>
    <link href="http://192.168.10.157:1234/iFixo_CRM/CSS/style_legend.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
    function ValidateOnDelete()
    {
    	var ret = confirm("Are you sure you want to delete the callback?");
    	if (ret == true)
    	{
    		event.returnValue = true;
    	}
    	else
    	{
    		event.returnValue = false;
    	}
    }
    </script>
    
    </head>
    <body bgcolor="#1BD6E0">
    	<table border="0" cellpadding="1" cellspacing="1" width="100%" >
    		<tr>
    			<td colspan="3" style="width:100%; height:5pt;"></td>
    		</tr>
    		<tr>
    			<td style="width:15%;"></td>
    			<td style="width:70%;">
    				<table border="1" cellpadding="1" cellspacing="1" width="90%" bgcolor="#FFFFFF">
    					<tr bgcolor="#9E9598">
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/Agent_Homepage.php">Home</a>
    						</td>
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/Create_Case.php">Create Case</a>
    						</td>
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/Create_Callback.php">Create Callback</a>
    						</td>
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/View_Callback.php">View Callback</a>
    						</td>
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/Agent_Change_Password.php">Change Password</a>
    						</td>
    						<td>
    							<a href="http://192.168.10.157:1234/iFixo_CRM/Agent_Logout.php">Logout</a>
    						</td>
    					</tr>
    					<tr>
    						<td colspan="6" style="width:100%;">
    							<table width="100%">
    								<tr>
    									<td align="right" valign="top" width="28%">Agent Name : </td>
    									<td align="right" valign="top" width="2%"></td>
    									<td align="left" valign="top" width="70%"><?php echo $agent_name; ?></td>
    								</tr>
    								<tr>
    									<td colspan="3" width="100%">
    										<table border="0" cellspacing="1" cellpadding="1" width="100%" >
    											<tr>
    												<td align="right" valign="top" width="15%" >	
    													<div class="foo" style="background-color:#FFFFFF;"></div>
    												</td>
    												<td align="left" valign="top" width="30%">Existing Customer</td>
    												<td align="center" valign="top" width="10%"></td>
    												<td align="right" valign="top" width="15%">	
    													<div class="foo" style="background-color:#F2CBC9;"></div>
    												</td>
    												<td align="left" valign="top" width="30%">Prospect Customer</td>
    											</tr>
    										</table>
    									</td>
    								</tr>
    								<tr>
    									<td colspan="3" width="100%">
    										<table border="1" cellspacing="1" cellpadding="1" width="100%" >
    											<tr bgcolor="#9E9598">
    												<td align="center" valign="top" width="20%">Customer Name </td>
    												<td align="center" valign="top" width="20%">Callback Date </td>
    												<td align="center" valign="top" width="20%">Callback Time </td>
    												<td align="center" valign="top" width="20%">Contact Number </td>
    												<td align="center" valign="top" width="10%">Edit </td>
    												<td align="center" valign="top" width="10%">Delete </td>
    											</tr>
    											<?php
    												include("config.php");
    												date_default_timezone_set('Asia/kolkata');
    												$sql = "Select * from callback where userid='$agent_id'";
    												$result = mysql_query($sql);
    												while($res = mysql_fetch_array($result))
    												{
    													if($res[6] == date("h:i:s"))
    													{
    														echo "<script>alert(\"you have a callback\");</script>";
    													}
    													if($res[7] == '0')
    													{
    											?>
    														<tr>
    															<td align="center" valign="top" width="20%"><?php echo $res[4]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[5]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[6]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[9]; ?></td>
    															<td align="center" valign="top" width="10%"><a href="editcallback.php?id=<?= $res[0];?>">edit</a></td>
    															<td align="center" valign="top" width="10%"><a href="deletecallback.php?id=<?=$res[0];?>" onclick="ValidateOnDelete()">delete</a></td>
    														</tr>
    											<?php 	}
    													else
    													{ 
    											?>
    														<tr bgcolor="#F2CBC9">
    															<td align="center" valign="top" width="20%"><?php echo $res[4]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[5]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[6]; ?></td>
    															<td align="center" valign="top" width="20%"><?php echo $res[9]; ?></td>
    															<td align="center" valign="top" width="10%"><a href="editcallback.php?id=<?= $res[0];?>">edit</a></td>
    															<td align="center" valign="top" width="10%"><a href="deletecallback.php?id=<?=$res[0];?>" onclick="ValidateOnDelete()">delete</a></td>
    														</tr>
    											<?php
    													}
    												}
    											?>
    										</table>
    									</td>
    								</tr>
    							</table>
    						</td>
    					</tr>
    				</table>
    			</td>
    			<td style="width:15%;"></td>
    		</tr>
    	</table>
    </body>
    </html>
    Last edited by keyboard; 08-14-2013 at 10:54 PM. Reason: Format: Code Tags [code][/code]

  2. #2
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,530
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    If you're never getting that alert, are you sure that if statement is firing?

    Code:
    if($res[6] == date("h:i:s"))
     {
    echo "<script>alert(\"you have a callback\");</script>";
     }
    Will $res[6] ever be equal to date("h:i:s")?

  3. #3
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry i didn't get your point...i'm a newbie in php..can you please suggest me what should i do???

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Since that line of code is inside a conditional block ( if ), you should check to see if it is even being run. The simplest way would be to check your output (i.e., the HTML markup) and see if that line is even printed.

    If it's not, then your condition ( $res[6] == date( "h:i:s" ) ) is evaluating to false - if those two values should be equivalent, you can investigate what is causing them not to be.

    If it is, then it's a javascript problem - we'd need to see your live page.

  5. #5
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey traq... thank you for taking out the time and trying to help me out..about "we'd need to see your live page." i cannot, as the live page is hosted on localhost..
    and the if condition is returning false..
    PHP Code:
    <?php
    include("config.php");
    date_default_timezone_set('Asia/kolkata');
    $sql "select * from callback where userid='1'";
    $result mysql_query($sql);
    while(
    $res mysql_fetch_array($result))
    {
        if(
    $res[6] == date("h:i:s"))
        {
         echo 
    "ok";
        }
        else
        {
         echo 
    "ko";
        }
    }
    ?>
    the output of the above code is -----> kokoko
    it got repeated three times as cuz the database callback had three diff datas in it..
    nOw, what to do??
    Last edited by keyboard; 08-15-2013 at 01:01 AM. Reason: Format: Php Tags [php][/php]

  6. #6
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    okay so i made a litle breakthorugh with the code...all i now need to do is refresh the page every sec using setinterval()..can you help me with this??
    <?php
    include("config.php");
    date_default_timezone_set('Asia/kolkata');
    $time = date("h:i:00");
    echo $time;

    $sql = "select * from callback where userid='1'";
    $result = mysql_query($sql);
    while($res = mysql_fetch_array($result))
    {
    if($res[6] == $time)
    {
    echo "ok";
    echo "<script>alert(\"you have a callback\");</script>";
    }
    else
    {
    echo "ko";
    }
    }

    the above code does output ok and displays alert when manually page is refreshed...

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Bikash View Post
    okay so i made a litle breakthorugh with the code...all i now need to do is refresh the page every sec using setinterval()..can you help me with this??
    With what? You haven't shown us any code involving setInterval. Are you asking how to use setInterval?

    Also, have you solved your earlier problem? You don't appear to have changed anything substantial in the code you posted. Was it simply not the correct time of day to work?


    Quote Originally Posted by Bikash View Post
    about "we'd need to see your live page." i cannot, as the live page is hosted on localhost.
    You can use an online service like jsfiddle or codepen.

  8. #8
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default yeah i was actually asking how can i use setinterval to refresh time automatically??

    Quote Originally Posted by traq View Post
    With what? You haven't shown us any code involving setInterval. Are you asking how to use setInterval?

    Also, have you solved your earlier problem? You don't appear to have changed anything substantial in the code you posted. Was it simply not the correct time of day to work?




    You can use an online service like jsfiddle or codepen.

    HTML Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <p id="demo"></p>
    <script>
    var myVar=setInterval(function(){myTimer()},1000);
    
    function myTimer()
    {
    var d=new Date();
    var t=d.toLocaleTimeString();
    document.getElementById("demo").innerHTML=t;
    }
    </script>
    
    </body>
    </html>
    this mytimer() shows my system time..how can i now compare it to my $res[6]??
    when they both are equal they will display a popup if not they wont do nything
    yes i do need this piece of code..so will be glad if nyone can help me with this
    Last edited by traq; 08-20-2013 at 03:14 AM. Reason: please use BBCode tags to format your post.

  9. #9
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Bikash View Post
    this mytimer() shows my system time..how can i now compare it to my $res[6]??
    when they both are equal they will display a popup if not they wont do nything
    Is this intended only for your local machine? Or are you developing it for a live website?

    There seems to be a bit of understanding you're missing: PHP happens on the server, while the user's local system clock... does not .

    You would need to poll the server every second (e.g., via AJAX). The server would then run the PHP script, which would query the database, compare the two values, and then return an appropriate value (your "popup" if successful; probably nothing otherwise). Then, you would use javascript to do something with that response - e.g., display it in a new window.

    There are many problems with this approach, not the least of which is efficiency. It's like sitting there, hitting the "refresh" button every second - if you have a significant number of users, you'll effectively launch a DOS attack on yourself. (I've actually done this before - with a script that posts live results to a darts tournament. It goes bad a lot faster than you'd imagine.) Querying the DB so often is also horribly inefficient.

    Next would be reliability - what if the system clock is not accurate? What if there is extra latency in the AJAX request? You might skip the matching time, or accidentally return "true" at the wrong time. How important is this?

    You might change your approach a bit - simply put the value of $res[6], and the popup URL, in the JS on the original page request. Let JS wait for the right time, and then display the popup.

    Edit: Some thing like this:
    Code:
    /* "zerosec" is retrieved from your DB and printed in the JS by php. */
    var zerotime = "06:45:00";
    
    setInterval( 
        /* this function will run... */
        function(){
            /* this is a _current_ date object */
            var countdown = new Date();
            /* get the time component */
            var now = countdown.toLocaleTimeString('en-US',{hour12:false});
            /* compare to zerotime */
            if( zerotime === now ){
                /* launch your popup */
            }
        }
        /* ...once every second */
        ,1000
    );
    working example on jsfiddle
    Last edited by traq; 08-20-2013 at 03:17 AM. Reason: added example.

  10. #10
    Join Date
    Aug 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Still no luck

    Quote Originally Posted by traq View Post
    Is this intended only for your local machine? Or are you developing it for a live website?

    There seems to be a bit of understanding you're missing: PHP happens on the server, while the user's local system clock... does not .

    You would need to poll the server every second (e.g., via AJAX). The server would then run the PHP script, which would query the database, compare the two values, and then return an appropriate value (your "popup" if successful; probably nothing otherwise). Then, you would use javascript to do something with that response - e.g., display it in a new window.

    There are many problems with this approach, not the least of which is efficiency. It's like sitting there, hitting the "refresh" button every second - if you have a significant number of users, you'll effectively launch a DOS attack on yourself. (I've actually done this before - with a script that posts live results to a darts tournament. It goes bad a lot faster than you'd imagine.) Querying the DB so often is also horribly inefficient.

    Next would be reliability - what if the system clock is not accurate? What if there is extra latency in the AJAX request? You might skip the matching time, or accidentally return "true" at the wrong time. How important is this?

    You might change your approach a bit - simply put the value of $res[6], and the popup URL, in the JS on the original page request. Let JS wait for the right time, and then display the popup.

    Edit: Some thing like this:
    Code:
    /* "zerosec" is retrieved from your DB and printed in the JS by php. */
    var zerotime = "06:45:00";
    
    setInterval( 
        /* this function will run... */
        function(){
            /* this is a _current_ date object */
            var countdown = new Date();
            /* get the time component */
            var now = countdown.toLocaleTimeString('en-US',{hour12:false});
            /* compare to zerotime */
            if( zerotime === now ){
                /* launch your popup */
            }
        }
        /* ...once every second */
        ,1000
    );
    working example on jsfiddle
    Hey Traq,
    I Tried and tried and kept on failing probably i was heading on a wrong direction,it can be done through AJAX, so can you help me get this done??
    1)Check if the time stored in database is equal to system time or not, if yes,then it will create an alert,if not then it wont do anything.
    2)But the catch is here, it will have to check the script continuously as to without disturbing the page state.

Similar Threads

  1. jquery callback href
    By ggalan in forum JavaScript
    Replies: 3
    Last Post: 12-15-2010, 02:07 AM
  2. AJAX Callback problem
    By bjkirkham in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 07-26-2010, 04:52 PM
  3. PHP Callback function needed
    By egturnkey in forum PHP
    Replies: 0
    Last Post: 04-21-2009, 08:29 AM
  4. Ajax callback function
    By dan0 in forum JavaScript
    Replies: 2
    Last Post: 12-01-2008, 09:10 PM
  5. Callback Reminder - Java Script
    By delltech in forum JavaScript
    Replies: 1
    Last Post: 04-28-2008, 08:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •