im trying to get php loop by ajax without refreshing page. I have this php loop for day time.
$druh = $_POST['druh'];
if ($druh == 30) {
$sekundy = 1800;
}
else {
$sekundy = 3600;
}
$datum = $date_final;
$iTimestamp = mktime(1,0,0,1,1,2014);
for ($i = 1; $i < 25; $i++) {
$vypis = $datum.' '.date('H:i:s', $iTimestamp) . "
<br />";
$iTimestamp += $sekundy;
echo $vypis;
}
this code give me this result -
2014-06-02 01:00:00
2014-06-02 02:00:00
2014-06-02 03:00:00
2014-06-02 04:00:00
2014-06-02 05:00:00
2014-06-02 06:00:00
2014-06-02 07:00:00
2014-06-02 08:00:00
2014-06-02 09:00:00
2014-06-02 10:00:00
2014-06-02 11:00:00
2014-06-02 12:00:00
2014-06-02 13:00:00
2014-06-02 14:00:00
2014-06-02 15:00:00
2014-06-02 16:00:00
2014-06-02 17:00:00
2014-06-02 18:00:00
2014-06-02 19:00:00
2014-06-02 20:00:00
2014-06-02 21:00:00
2014-06-02 22:00:00
2014-06-02 23:00:00
2014-06-02 00:00:00
And last one is my ajax code -
$(function(){
$("#obojebtn2").click(function(){
$('#stkbtn2').fadeOut(300);
$('#emisebtn2').fadeOut(300);
$('#obojebtn2').fadeOut(300);
$('#jinebtn2').fadeOut(300);
$.ajax({
url: 'http://podivej.se/script_cas.php',
data: {druh: '60'},
type: "POST",
datatype: 'json',
success: function(data){
$('#result').html();
}
});
});
});
I need in the #result div show this php loop after sumbit a button - #obojebtn2. I google a lot and i found that i have to you JSON encode for it but i really dont know how to use it on loop.
Can you give me any advice?