Problema com POST PHP+JAVASCRIPT
$.ajax({
type: "POST",
url: "/contato",
data: {
"name": $("#footer-form #name2").val(),
"email": $("#footer-form #email2").val(),
"fone": $("#footer-form #fone2").val(),
"subject": $("#footer-form #subject2").val(),
"message": $("#footer-form #message2").val()
},
dataType: "json",
success: function (data) {
if (data.sent == "yes") {
$("#MessageSent2").removeClass("hidden");
$("#MessageNotSent2").addClass("hidden");
$(".submit-button").removeClass("btn-default").addClass("btn-success").prop('value', 'Mensagem enviada');
$("#footer-form .form-control").each(function() {
$(this).prop('value', '').parent().removeClass("has-success").removeClass("has-error");
});
} else {
$("#MessageNotSent2").removeClass("hidden");
$("#MessageSent2").addClass("hidden");
}
}
})
$router = new \Bramus\Router\Router();
// Check JWT on /secured routes. This can be any route you like
$router->before('GET', '/secured/.*', function () {
// This method will exist if you're using apache
// If you're not, please go to the extras for a defintion of it.
$requestHeaders = apache_request_headers();
$authorizationHeader = $requestHeaders['Authorization'];
if ($authorizationHeader == null) {
header('HTTP/1.0 401 Unauthorized');
echo "No authorization header sent";
exit();
}
});// Controllers API
$router->get('/ping', function () {
$dado = array(
"status" => 'ok',
"message" => 'Everybody can do this...'
);
echo json_encode($dado);
});
$router->get('/secured/ping', function () {
echo "All good. You only get this message if you're authenticated";
});
// Run the Router
$router->run();
// Activate CORS
function sendCorsHeaders()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Authorization");
header("Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE");
}
$router->options('/.*', function () {
sendCorsHeaders();
});
sendCorsHeaders();
>
erros:no-referrer-when-downgrade-origin-when-cross-origin
Provisional headers are show
eu ja tive esse problema anteriormente e usei essa classe + esses header para resolver em um site de um cliente problema que nesse site que estou trabalhando não está resolvendo.
Discussão (0)
Carregando comentários...