Re: Cant figure out ajax/php problem.



On Fri, 26 Oct 2007 18:17:00 +0200, John Doe <dod@xxxxxxx> wrote:


<etbalex@xxxxxxxxx> wrote in message
news:1193325679.155875.118250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
.



Relevant Pages

  • Re: trying to write php/ajax instant messenger.
    ... basically an ajax IM feature. ... a div on my main page that runs a javascript timer to load the php page via ... then echoes them to a div on the page. ... I tried just echo'ing the javascript to do an alert();, ...
    (comp.lang.php)
  • Re: trying to write php/ajax instant messenger.
    ... the various JavaScript frameworks. ... basically an ajax IM feature. ... then echoes them to a div on the page. ... I tried just echo'ing the javascript to do an alert();, ...
    (comp.lang.php)
  • Re: AJAX Problem. JavaScript not working if i push it to Updatepanels content.
    ... familiar yet with AJAX but looks like an expected behavior to me. ... Just programmtically add some script in the already loaded ... Using postback i am adding a JavaScript snippet and a DIV inside a ... The Javascript is written too. ...
    (microsoft.public.dotnet.framework)
  • Re: Onload from within Ajax
    ... Ajax scripting. ... Google will provide plenty of links: "innerhtml javascript not executed" ... then extracting the script parts and eval'ing them. ... var el = document.getElementById; ...
    (comp.lang.javascript)
  • Re: Onload from within Ajax
    ... Ajax scripting. ... The suggestions recommend something like appending the innerHTML string, ... then extracting the script parts and eval'ing them. ... var el = document.getElementById; ...
    (comp.lang.javascript)