Nie wiem dlaczego to nie działa.
<?php
(!isset($_GET['step'])) ? $_GET['step'] = 'form' : $_GET['step'] = $_GET['step'];
switch($_GET['step']):
case 'form':
?>
<style type="text/css">
.loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url('ajax-load.gif') 50% 50% no-repeat rgba(249,249,249,.8);
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function() {
$.ajax({
type: "POST",
url: "index.php?step=save",
cache: 'false',
data: $("#form").serialize(),
beforeSend: function() {
$('.ajax').html('<img class="loader" />').show();
},
dataType: "html",
success: function(result) {
$("#error_message").html(result);
$(".ajax").fadeOut("slow");
window.location.href = 'index.php?step=thx';
},
error: function(xhr, ajaxOptions, thrownError) {
alert('Something went wrong. Please try again.');
$(".ajax").fadeOut("slow");
}
});
return false;
});
});
</script>
<?php
print "<form action=\"\" method=post id=form>";
print "<input type=\"text\" name=\"to\" />";
print "<input id=submit type=\"submit\" value=\"okkk\" /></form>";
print "<div class=\"ajax\"></div>";
exit();
break;
case 'save':
print "save";
break;
default:
header("location: " . $_SERVER['SCRIPT_NAME']);
break;
exit();
endswitch;
?>
Nie wiem tez co mam dac konkretnie do pola ACTION w formularzu. Ścieżkę do pliku z parametrem ? tyle ze w JS jest już ścieżka chyba że ja to źle robię.
nie działa
? Opisz konkretnie co się (nie)dzieje i popraw tytuł wątku (https://4programmers.net/Pomoc/Forum_dyskusyjne/Jak_tytu%C5%82owa%C4%87_w%C4%85tki_na_forum).