I have been using Ajax mainly to be used as a POST, to take care of thinks, but now wanted just to open a simple login page into a DIV (and is doing it) but now the problem comes when I have added this to the PHP code:
<?php
if (isset($_POST))
{
}
else
{
echo "
<html>
<head>
<meta charset='utf-8'>
<link rel='stylesheet' type='text/css' href='assets/css/main.css'>
</head>
<body>
<div class='page-header'>
<h1>Preencha os campos e carregue em enviar</h1>
</div>
<form>
<div class='form-group'>
<label for='exampleInputEmail1'>Endereço Email</label>
<input type='email' class='form-control' id='exampleInputEmail1' placeholder='Email'>
</div>
<div class='form-group'>
<label for='exampleInputPassword1'>Palavra-Pass</label>
<input type='password' class='form-control' id='exampleInputPassword1' placeholder='Palavra-Pass'>
</div>
<button type='submit' class='btn btn-default'>Enviar</button>
</form>
</body>
</html>";
}
and this is the Ajax code:
$(function() {
$('.navmenu a').bind('click', function(event) {
event.preventDefault();
var urlToGo = $(this).attr('href');
if ($( window ).width() <= "992" && !$(this).hasClass('dropdown-toggle'))
{
$('.navmenu').offcanvas('hide');
}
$.ajax({
url: urlToGo,
dataType: 'html',
success: function(result)
{
$(".container").html(result);
}
});
$('html,body').animate({
scrollTop: 0
}, 700);
console.log(urlToGo);
});
});
When I press the link to be used to use the Ajax, it will put a empty page on the div container, what I'm doing wrong in here? If I Change the (isset($_POST)) to (!isset($_POST)) it will show the content right, and I don't wanted this to be a post.
What is wrong in the logic here ?!
Thanks in advance