The idea is to take the value from the input [name="path"] and use it as the url value of the method AJAX. But my console is showing that this value is Undefined .
I could not figure out why yet.
My HTML:
<a class="rtrn-conteudo" objeto="form_objeto">Logout</a>
<form id="form_objeto">
<input type="hidden" name="flag" value="logout"/>
<input type="hidden" name="caminho" value="meu/caminho/aqui.nesse.formato"/>
</form>
My JQuery:
$(document).ready(function() {
$("body")
.on("click", ".rtrn-conteudo", function(event) {
var objeto = new FormData(document.querySelector("#" + $(this).attr("objeto")));
$.ajax({
url: objeto["caminho"], //Detalhe: se eu usar "meu/caminho/aqui.nesse.formato" escrito direto, funciona.
data: objeto,
type: 'post',
processData: false,
contentType: false,
success: function(retornoDados) {
$("body").html(retornoDados);
}
});
});
});