AJAX? + PHP + .txt

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hugo F
Forum Newbie
Posts: 5
Joined: Wed Jan 23, 2008 10:37 am
Location: Portugal

AJAX? + PHP + .txt

Post by Hugo F »

Hello,

I have a file .txt (it's read in php page with ajax) and which is empty, but once you get anything I wanted to open a URL in a pop-up automatically.

How?

Thanks,
Hugo Fernandes
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: AJAX? + PHP + .txt

Post by Zoxive »

We are going to need a better description of your question, and possibly even code to reference.

I have no idea what you are asking.

All I can understand is:
  • You have a Txt File
  • Text File is being opened with php, from a Ajax call
  • ??
Hugo F wrote:but once you get anything I wanted to open a URL in a pop-up automatically.
Get the Servers Response from the Ajax call?
Hugo F
Forum Newbie
Posts: 5
Joined: Wed Jan 23, 2008 10:37 am
Location: Portugal

Re: AJAX? + PHP + .txt

Post by Hugo F »

Zoxive wrote:We are going to need a better description of your question, and possibly even code to reference.

I have no idea what you are asking.

All I can understand is:
  • You have a Txt File
  • Text File is being opened with php, from a Ajax call
  • ??
Hugo F wrote:but once you get anything I wanted to open a URL in a pop-up automatically.
Get the Servers Response from the Ajax call?

I have this:

Code: Select all

 
<html>
<head>  
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 
<script src="prototype.js" type="text/javascript"></script>
<script src="scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">   var ajaxPopulater = function (id,url)
{    url  = url + '?StopCache=' + new Date;    new Ajax.PeriodicalUpdater(id, url,       
{     method: 'post',    frequency: 0.5,     asynchronous: true,     decay: 0.5    });   }  </script>
  <title>TestAjax</title> 
</head>
<body onload="javascript&#058;ajaxPopulater('latest','test.txt')">
 
<div id="as">
 
</div>
<div id="latest"></div>
 
 
</body>
</html>
 
It's work!

1º The file is empty.

2º The file isn´t empty

3º Appears the new data and the code I have post show the new data (it's work)

4º Open URL in Pop-up (when the file isn´t empty) - (this is my quest)
Hugo F
Forum Newbie
Posts: 5
Joined: Wed Jan 23, 2008 10:37 am
Location: Portugal

Re: AJAX? + PHP + .txt

Post by Hugo F »

No idea??
Hugo F
Forum Newbie
Posts: 5
Joined: Wed Jan 23, 2008 10:37 am
Location: Portugal

Re: AJAX? + PHP + .txt

Post by Hugo F »

:arrow: Please help me!
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: AJAX? + PHP + .txt

Post by pickle »

To answer your question (or at least move it along), when you get a response to your AJAX call, do you not know then what the contents of the file were? You can do a simple

Code: Select all

if(ajaxContents != ''){     alert('Popup message');}
You can replace the alert() with window.open() if necessary.


Is the PHP side working? If so, this is a client-side question & I can move it there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Hugo F
Forum Newbie
Posts: 5
Joined: Wed Jan 23, 2008 10:37 am
Location: Portugal

Re: AJAX? + PHP + .txt

Post by Hugo F »

Is the client-side.

But if exist any resolution...

Tanks,
Hugo
Post Reply