Cant figure out ajax/php problem.

Cant figure out ajax/php problem.

am 22.10.2007 08:04:20 von john doe

Here's my issue: I have an instant messenger type feature for my site, its
basically an ajax IM feature. I run with a mysql backend on the site, i have
a div on my main page that runs a javascript timer to load the php page via
ajax every 15 seconds which checks the "pinguser" table to see if the user
has any chat requests, then echoes them to a div on the page. what i REALLY
want to do is have the ajax page see if there is a ping for the user, and if
so, pop up a javascript alert or somethign to let the user know he has a
chat request. I tried just echo'ing the javascript to do an alert(); , or
even a window.open. It works if i just run the script by itself, but when it
runs in the div on my main page, i get the rest of the feedback (it displays
the message i echo'ed that said "youve got mail", but the alert box doesnt
pop up. Anyone have any idea what Im doing wrong? I've been googling for 3
days straight and going crazy, never thought to check the groups before.

Re: Cant figure out ajax/php problem.

am 22.10.2007 18:37:16 von Steve

"John Doe" wrote in message
news:02783240$0$29357$c3e8da3@news.astraweb.com...
> Here's my issue: I have an instant messenger type feature for my site, its
> basically an ajax IM feature. I run with a mysql backend on the site, i
> have a div on my main page that runs a javascript timer to load the php
> page via ajax every 15 seconds which checks the "pinguser" table to see if
> the user has any chat requests, then echoes them to a div on the page.
> what i REALLY want to do is have the ajax page see if there is a ping for
> the user, and if so, pop up a javascript alert or somethign to let the
> user know he has a chat request. I tried just echo'ing the javascript to
> do an alert(); , or even a window.open. It works if i just run the script
> by itself, but when it runs in the div on my main page, i get the rest of
> the feedback (it displays the message i echo'ed that said "youve got
> mail", but the alert box doesnt pop up. Anyone have any idea what Im doing
> wrong? I've been googling for 3 days straight and going crazy, never
> thought to check the groups before.

it does no one any good to ficticously guess at what your problem is, and
feckless to divine a solution.

here is what i can say...this is NOT a php question. further, if you just
want to load the html/page again, you don't need javascript to do that! you
need to isolate functionality and use xml to communicate messages to/from
the server, and then use javascript to update only the pertenant area(s) or
the current page in the browser.

either ask your *javascript* question in a *javascript* newsgroup, or get
flak here. either way, no one will do shit for you until you post sample
code.

Re: Cant figure out ajax/php problem.

am 22.10.2007 18:37:16 von Steve

"John Doe" wrote in message
news:02783240$0$29357$c3e8da3@news.astraweb.com...
> Here's my issue: I have an instant messenger type feature for my site, its
> basically an ajax IM feature. I run with a mysql backend on the site, i
> have a div on my main page that runs a javascript timer to load the php
> page via ajax every 15 seconds which checks the "pinguser" table to see if
> the user has any chat requests, then echoes them to a div on the page.
> what i REALLY want to do is have the ajax page see if there is a ping for
> the user, and if so, pop up a javascript alert or somethign to let the
> user know he has a chat request. I tried just echo'ing the javascript to
> do an alert(); , or even a window.open. It works if i just run the script
> by itself, but when it runs in the div on my main page, i get the rest of
> the feedback (it displays the message i echo'ed that said "youve got
> mail", but the alert box doesnt pop up. Anyone have any idea what Im doing
> wrong? I've been googling for 3 days straight and going crazy, never
> thought to check the groups before.

it does no one any good to ficticously guess at what your problem is, and
feckless to divine a solution.

here is what i can say...this is NOT a php question. further, if you just
want to load the html/page again, you don't need javascript to do that! you
need to isolate functionality and use xml to communicate messages to/from
the server, and then use javascript to update only the pertenant area(s) or
the current page in the browser.

either ask your *javascript* question in a *javascript* newsgroup, or get
flak here. either way, no one will do shit for you until you post sample
code.

Re: Cant figure out ajax/php problem.

am 25.10.2007 17:21:19 von etbalex

Why not try another Div for messages or alerts, whenever you need to
display an alert make the DIV visible via CSS.

Re: Cant figure out ajax/php problem.

am 25.10.2007 17:21:19 von etbalex

Why not try another Div for messages or alerts, whenever you need to
display an alert make the DIV visible via CSS.

Re: Cant figure out ajax/php problem.

am 26.10.2007 18:17:00 von john doe

wrote in message
news:1193325679.155875.118250@d55g2000hsg.googlegroups.com.. .
> Why not try another Div for messages or alerts, whenever you need to
> display an alert make the DIV visible via CSS.
>

Well I have a DIV that messages display in that is refreshed via ajax every
5 seconds or so. basically, when someone sends a chat request, it just adds
a record to a mysql database, then the ajax that refreshes that DIV on my
page checks the database to see if there are any new chat requests.
Unfortunately I can't seem to get any type of javascript to work when I call
it in my PHP script that is being called by AJAX. (basically, the ajax
loads up a refresh.php that simply checks the database, then echoes a
message back to the div that says "Chat request incoming from blah blah
blah). When i try to embedd some javascript into the page to do a quick
alert("Youve Got Mail") the alert doesnt pop up, even though the rest of the
script (the php part) executes correctly. If i run the PHP script by itself,
the alert does pop up. I just dont know a whole lot about when javascript
will work and when it won't, i am kind of baffled by the problem. Its just
weird because it works when i run the update script seperately, but not when
run as an AJAX call.

Re: Cant figure out ajax/php problem.

am 26.10.2007 18:17:00 von john doe

wrote in message
news:1193325679.155875.118250@d55g2000hsg.googlegroups.com.. .
> Why not try another Div for messages or alerts, whenever you need to
> display an alert make the DIV visible via CSS.
>

Well I have a DIV that messages display in that is refreshed via ajax every
5 seconds or so. basically, when someone sends a chat request, it just adds
a record to a mysql database, then the ajax that refreshes that DIV on my
page checks the database to see if there are any new chat requests.
Unfortunately I can't seem to get any type of javascript to work when I call
it in my PHP script that is being called by AJAX. (basically, the ajax
loads up a refresh.php that simply checks the database, then echoes a
message back to the div that says "Chat request incoming from blah blah
blah). When i try to embedd some javascript into the page to do a quick
alert("Youve Got Mail") the alert doesnt pop up, even though the rest of the
script (the php part) executes correctly. If i run the PHP script by itself,
the alert does pop up. I just dont know a whole lot about when javascript
will work and when it won't, i am kind of baffled by the problem. Its just
weird because it works when i run the update script seperately, but not when
run as an AJAX call.

Re: Cant figure out ajax/php problem.

am 26.10.2007 21:04:12 von luiheidsgoeroe

On Fri, 26 Oct 2007 18:17:00 +0200, John Doe wrote:

>
> wrote in message
> news:1193325679.155875.118250@d55g2000hsg.googlegroups.com.. .
>> Why not try another Div for messages or alerts, whenever you need to
>> display an alert make the DIV visible via CSS.
>>
>
> Well I have a DIV that messages display in that is refreshed via ajax
> every
> 5 seconds or so. basically, when someone sends a chat request, it just
> adds
> a record to a mysql database, then the ajax that refreshes that DIV on my
> page checks the database to see if there are any new chat requests.
> Unfortunately I can't seem to get any type of javascript to work when I
> call
> it in my PHP script that is being called by AJAX. (basically, the ajax
> loads up a refresh.php that simply checks the database, then echoes a
> message back to the div that says "Chat request incoming from blah blah
> blah). When i try to embedd some javascript into the page to do a quick
> alert("Youve Got Mail") the alert doesnt pop up, even though the rest of
> the
> script (the php part) executes correctly. If i run the PHP script by
> itself,
> the alert does pop up. I just dont know a whole lot about when
> javascript
> will work and when it won't, i am kind of baffled by the problem. Its
> just
> weird because it works when i run the update script seperately, but not
> when
> run as an AJAX call.

Ask about this in comp.lang.javascript, mentioning 'executing code
retrieved by XMLHTTPRequest'.
Short answer: inline code will execute on a pageload, after the page has
loaded you can add all the inline code with js you want, it won't fire
unless explicitly called by some script already running or scheduled to
run. This had nothing with the fact wether or not this is done by PHP, or
just a static HTML page retrieving a static HTML snippet.
--
Rik Wasmus

Re: Cant figure out ajax/php problem.

am 20.12.2007 10:01:29 von My Pet Programmer

Ok, seriously, without code, we're not going to be able to help at all.

~A!

John Doe took the time to say:
> wrote in message
> news:1193325679.155875.118250@d55g2000hsg.googlegroups.com.. .
>> Why not try another Div for messages or alerts, whenever you need to
>> display an alert make the DIV visible via CSS.
>>
>
> Well I have a DIV that messages display in that is refreshed via ajax every
> 5 seconds or so. basically, when someone sends a chat request, it just adds
> a record to a mysql database, then the ajax that refreshes that DIV on my
> page checks the database to see if there are any new chat requests.
> Unfortunately I can't seem to get any type of javascript to work when I call
> it in my PHP script that is being called by AJAX. (basically, the ajax
> loads up a refresh.php that simply checks the database, then echoes a
> message back to the div that says "Chat request incoming from blah blah
> blah). When i try to embedd some javascript into the page to do a quick
> alert("Youve Got Mail") the alert doesnt pop up, even though the rest of the
> script (the php part) executes correctly. If i run the PHP script by itself,
> the alert does pop up. I just dont know a whole lot about when javascript
> will work and when it won't, i am kind of baffled by the problem. Its just
> weird because it works when i run the update script seperately, but not when
> run as an AJAX call.
>
>

Re: Cant figure out ajax/php problem.

am 20.12.2007 10:01:29 von My Pet Programmer

Ok, seriously, without code, we're not going to be able to help at all.

~A!

John Doe took the time to say:
> wrote in message
> news:1193325679.155875.118250@d55g2000hsg.googlegroups.com.. .
>> Why not try another Div for messages or alerts, whenever you need to
>> display an alert make the DIV visible via CSS.
>>
>
> Well I have a DIV that messages display in that is refreshed via ajax every
> 5 seconds or so. basically, when someone sends a chat request, it just adds
> a record to a mysql database, then the ajax that refreshes that DIV on my
> page checks the database to see if there are any new chat requests.
> Unfortunately I can't seem to get any type of javascript to work when I call
> it in my PHP script that is being called by AJAX. (basically, the ajax
> loads up a refresh.php that simply checks the database, then echoes a
> message back to the div that says "Chat request incoming from blah blah
> blah). When i try to embedd some javascript into the page to do a quick
> alert("Youve Got Mail") the alert doesnt pop up, even though the rest of the
> script (the php part) executes correctly. If i run the PHP script by itself,
> the alert does pop up. I just dont know a whole lot about when javascript
> will work and when it won't, i am kind of baffled by the problem. Its just
> weird because it works when i run the update script seperately, but not when
> run as an AJAX call.
>
>