I have the following function that is called when I click on a button to submit a form:
function dadosFormularios(preenchimentoForm){
//var path = document.location.pathname;
//alert(path);
alert(preenchimentoForm);
//window.location.href = 'wp-content/themes/template/index.php';
var qstringA = '';
//dados dos campos
var nome=document.getElementById("nome").value;
qstringA = 'nome='+ nome;
//alert(qstringA);
if(preenchimentoForm==false){
alert('Please correct the errors in the Form');
}
else{
if(preenchimentoForm==true){
window.location.href = 'index.php?'+qstringA;
return false;
}
}
}
Since I’m using this way of processing the data, how can I alert my page index.php that the data sent by the function arrived on the index? I can’t use a if (isset($_POST['button']..) since I send the information by the function and not through the button of the form, right?
window.location.href = 'index.php?'+qstringA;This line is just redirecting to index.php with a query string
?nome=nome_value.For example.
index.php?nome=nome_valueSo, in your
index.phpYou can simply get everything posted with$_GET.Check it by doing a
print_r($_GET);there.In
index.php, you can simply checkP.S. Although, without knowing the other circumstances or reasons behind usage of this function, it can be said that this function is just doing what a simple
<form action=index.php>would have done.P.P.S. Although you have mentioned
jQueryin title and also tagged it, I am not sure this function is using any of the jQuery code. I think it is just a simpleJavascriptfunction.