I made a script for newsletter subscription, the user sends the email to cadastre.php and from there the script receives an echo in a message with a button, the problem is that the button does not appear, what appears is the tag, see :
Script:
$(function()
{
$("#ok").click(function()
{
$("#formulario_news").hide("slow");
BeforeSend:$("#carregando_news").show("slow");
var email = $("#email").val();
$.post("<?php bloginfo('template_directory');?>/newsletter/cadastro.php",{email: email}, function(data)
{
complete:$("#carregando_news").hide("slow");
$("#retorno").show("slow").text(data);
$("#voltar").click(function()
{
$("#retorno").hide("slow");
$("#formulario_news").show("slow");
});
});
});
});
<div id="newsletter">
<h1>/Assine nosso newsletter</h1>
<div id="formulario_news">
<span>Informe seu email:</span>
<input type="text" id="email" name="email"/>
<input type="submit" name="ok" id="ok" class="btn_ok" value="OK"/>
</div>
<div id="carregando_news" style="display:none;">
<img src="<?php bloginfo('template_directory'); ?>/imagens/ajax-loader.gif"/> <p> Aguarde, enviando...</p>
</div> <!-- Carregando newsletter -->
<div id="retorno" style="padding:10px;border:1px solid #0F0;background:#C1FFD1;width:170px;margin-left:3px;margin-bottom:3px;display:none;font:14px Trebuchet;
font-weight:bold;">
</div>
</div>
cadastro.php:
$email = strip_tags(trim($_POST['email']));
if(empty($email))
{
echo "Informe seu email</br>";
echo "<button type="button" id="voltar"/>Voltar</button>";
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
echo "Informe um email válido</br>";
echo "<button type="button" id="voltar"/>Voltar</button>";
}
Let's assume that the user does not enter the email and click the OK button. The return is this:
Informe seu email</br>
<button type="button" id="voltar"/>Voltar</button>
The tags appear written, the browser does not jump line and the button does not appear.