473,473 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cant figure out ajax/php problem.

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.
Oct 22 '07 #1
6 1935

"John Doe" <do*@dad.cogwrote in message
news:02**********************@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.
Oct 22 '07 #2
Why not try another Div for messages or alerts, whenever you need to
display an alert make the DIV visible via CSS.

Oct 25 '07 #3

<et*****@gmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.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.
Oct 26 '07 #4
On Fri, 26 Oct 2007 18:17:00 +0200, John Doe <do*@dad.cogwrote:
>
<et*****@gmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.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
Oct 26 '07 #5
Ok, seriously, without code, we're not going to be able to help at all.

~A!

John Doe took the time to say:
<et*****@gmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.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.

Dec 20 '07 #6
Rob
On Oct 22, 4:37 pm, "Steve" <no....@example.comwrote:
"John Doe" <d...@dad.cogwrote in message

news:02**********************@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.
John, assuming you're using 'prototype' for your AJAX, it has a
"evalScripts: true" parameter - have you set this?

If not, you may be running into the same problem that this parameter
tries to deal with.

Either way, I would suggest converting your code to use prototype.
You can then call your <divcontent in a single line of code, and not
have to worry about what's going on in the background too much.

Rob.
Dec 20 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Dan K. | last post by:
Hi Folks, Problem is, that on one of my controls the DEL key wont work in textboxes. i have different controls of this kind in my app and this is the only one the DEL Key wont do his job....
2
by: Scott McDaniel | last post by:
The code below cannot locate the Textbox "tbDuration" in my ASP.NET 2.0 page. <Ajax.AjaxMethod()> _ Public Function calcTimeSpan(ByVal StartTime As String, ByVal EndTime As String) As String Dim...
2
by: g35rider | last post by:
Hi, I have the following code that is giving this error, I cant simplify the code, I was just testing some theory for something we are doing and was getting an issue here. Please someone point out...
4
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this...
3
by: equazcion | last post by:
Hi, I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
7
by: mitchell | last post by:
hi i m using IE 6.0. i want to refresh just the captcha part when the user clicks on an image. i searched for articles on it and got a fairly good understanding of it. but i m still unable to...
3
by: John Doe | last post by:
Heres what I am trying to do: I have a div on my web site that runs a little php page via ajax with a javascript timer every 15 seconds or so. I can get the php page to load up the database i...
6
by: WolfgangS | last post by:
Ok first off, i am a total beginner at this groups stuff and i have no clue how this works. This is probabaly the wrong group for my problem but i will post it anyways. Learning by doing right? ...
5
by: chevon1920 | last post by:
I am trying to do my assignment but I cant figure out how to get 8 data points per line to print to a file. Here is the assignment 1. Program asks the user to enter an odd number as a BASE,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.