Thread View: pl.comp.lang.javascript
2 messages
2 total messages
Started by Adam Wójcik
Sun, 16 May 2010 11:48
Odświeżanie treści
Author: Adam Wójcik
Date: Sun, 16 May 2010 11:48
Date: Sun, 16 May 2010 11:48
8 lines
1049 bytes
1049 bytes
Witam Czy ktos moglby mi powiedziec jak jest zrobione odswiezanie dowcipow na stronie http://www.1000kawalow.pl/google (link "Następny dowcip")?? To jest jakaś funkcja JS? pozdrawiam ADAM
Re: Odświeżanie treści
Author: fuzjusz
Date: Sun, 16 May 2010 14:16
Date: Sun, 16 May 2010 14:16
79 lines
2796 bytes
2796 bytes
On 16 Maj, 13:48, Adam Wójcik <adam.w...@gazeta.pl> wrote:
> [..] odswiezanie [..] To jest jakaś funkcja JS?
to zabawa obiektem XMLHttpRequest.
poszukaj o ajax.
poniżej prosty przykład:
---
md5.php
---
<?php
if(isset($_GET['x'])) echo md5($_GET['x']);
?>
---
eof
---
index.htm
---
<html>
<head>
<script type="text/javascript">
var daneserwera;
function doszlo(){
if(daneserwera.readyState == 4){
document.getElementById("prz").value = "md5@serwer";
document.getElementById("txt").value = daneserwera.responseText;
}
}
function slij(){
document.getElementById("prz").value = "loading...";
daneserwera.open("GET", "md5.php?x=" +
document.getElementById("txt").value + "&s=" + Math.random(), true);
daneserwera.send(null);
}
function aajjaaxx(){
try{
daneserwera = new XMLHttpRequest(); // ff, o, safari
}catch(e){
try{
daneserwera = new ActiveXObject("Msxml2.XMLHTTP"); //ie
}catch(e){
try{
daneserwera = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
alert("nie ma ajaxa");
return false;
}
}
}
daneserwera.onreadystatechange = doszlo;
document.getElementById("prz").onclick = slij;
}
window.onload = aajjaaxx;
</script>
</head>
<body>
<table style="height:100%;width:100%">
<tr>
<td style="width:100%">
<input type="text" value="napisik" id="txt" style="width:100%" />
</td>
<td style="width:0%">
<input type="button" value="md5@serwer" id="prz" />
</td>
</tr>
</table>
</body>
</html>
---
eof
---
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads