Link to home
Start Free TrialLog in
Avatar of mgtm3
mgtm3Flag for Israel

asked on

how can i make ajax call a php file every one second using javascript?

i have a script that gets the updates from a database and i thought i would be cool if i make it ajax so that the script updates every one second with out clicking on refresh

can i have a script?
SOLUTION
Avatar of drowning_in_the_how
drowning_in_the_how
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, right:

"i thought i would be cool if i make it ajax so that the script updates every one second" (sic)

What is "cool" about dragging your page to its knees?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgtm3

ASKER

thank you striker46 it works great just one problem the things that comeback from the boo.php is in arabic and when i get them back in ajax i get them not in arabic but in ý ýýý   how can i fix this
Let's see if I understand it well: the data retrieved from the MySQL database is stored there in arabic, but it is appears in the page as ýýýýý? Could be related with encoding...
Avatar of mgtm3

ASKER

noo when i get the data not using ajax i get it in arabic but now in ajax i get it all wrong
Can you please post the code you use to retrieve the data without AJAX?
I'll do some tests meanwhile
Avatar of mgtm3

ASKER

<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />

<?php
include 'sql.php';


$select ="SELECT * FROM posts order by id desc limit 50";
  $re = mysqli_query($mysqli,$select);

?><table width="100%"><?php
  while ($row=mysqli_fetch_array($re)){
  ?>
<tr><td><table align="right" ><tr align="right"><td><div align="right"><a href="get.php?id=<?php echo $row['id'];?>">more>></a></div></td><td  ><div align="right">
  <?php
echo $row['topic']."   ".$row['posts']." *9DJB "."   ".$row['forumid'];
?>
</div>
  <font style="font-weight:900"></td><td><div align="right"><?php echo $row['id'];?></div>
  </td>
</tr></table></td></tr>
</font><?php } ?>
</table>
Avatar of mgtm3

ASKER


<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
 
<?php
include 'sql.php';
 
 
$select ="SELECT * FROM posts order by id desc limit 50";
  $re = mysqli_query($mysqli,$select);
 
?><table width="100%"><?php
  while ($row=mysqli_fetch_array($re)){
  ?>
<tr><td><table align="right" ><tr align="right"><td><div align="right"><a href="get.php?id=<?php echo $row['id'];?>">more>></a></div></td><td  ><div align="right">
  <?php
echo $row['topic']."   ".$row['posts']." *9DJB "."   ".$row['forumid'];
?>
</div>
  <font style="font-weight:900"></td><td><div align="right"><?php echo $row['id'];?></div>
  </td>
</tr></table></td></tr>
</font><?php } ?>
</table>

Open in new window

Try adding to the boo.php file the following line:

<?php header('Content-Type: text/html; charset=windows-1256');?>

Let's see if it helps.
Avatar of mgtm3

ASKER

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh striker46 you are my hero thanksssssssssssssssssss
Glad to know you got it to work!