FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Ajax Alerts

 


DanielXP
Im am using ajax to check for site alerts.

I have made a alert system what will send an alert to all the users online at that time.

But i wont work with the ajax.

On the alerts.php i have this
Code:
echo "<SCRIPT language=\"JavaScript\">   
alert('$alert[message]');   
</SCRIPT>";


Note: Thats not the full code but thats what will do the alert

Then i update the alerts with the ajax what go into this
Code:
<div id="alerts" width='100%' height='100%'></div>


Using
Code:
document.getElementById("alerts").innerHTML = xmlHttp.responseText;


What gets the html form the alerts page.

I have tested the alerts just by refresh on my own and it works fine.

But when it comes to displaying it with the ajax it wont let me do it.

Is there a way around this.

Thanks DanielXP
Lucanos
Hi Damien,

Rather than having AJAX call a PHP script which creates a page which contains a JavaScript action... etc.

Why not simply have the PHP script return the content of the alarm, and have the AJAX action do something like:

Code:
if ( xmlHttp.responseText!="" ) {
  alert(xmlHttp.responseText);
}


So whatever is returned by the AJAX call, as the content of that page, is used as the body of the alert?
DanielXP
O yer i could add that to the code

I will have to include it in a the same funtion coz the alerts has more alert things on it not just java alerts

So will the other alerts just have to echo what it says in the DB?
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.