Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
表单错误-提交时单击打开下载mail.php的窗口_Php_Jquery_Forms - Fatal编程技术网

表单错误-提交时单击打开下载mail.php的窗口

表单错误-提交时单击打开下载mail.php的窗口,php,jquery,forms,Php,Jquery,Forms,我在web上创建了一个表单联系人,但当我单击“Enviar”(提交按钮)时,表单电子邮件会到达,但它会打开一个窗口来下载mail.php,而不是显示真正的表单结果。错误在哪里? 你可以在这里看到它: 这是表单的web代码: <!doctype html> <html> <head> <script type="text/javascript" src="formValidar/formValidar.js"></script> <

我在web上创建了一个表单联系人,但当我单击“Enviar”(提交按钮)时,表单电子邮件会到达,但它会打开一个窗口来下载mail.php,而不是显示真正的表单结果。错误在哪里? 你可以在这里看到它:

这是表单的web代码:

<!doctype html>
<html>
<head>
<script type="text/javascript" src="formValidar/formValidar.js"></script>
</head>
<body>
        <div class="formulario">
           <!--form-->
           <form id="web" method="POST" action="mail.php">
            <div class="campos">     
                <div class="caja">
                    <div class="flecha"></div>
                    <label class="tituloform" for="nombre">Nombre Completo
                    <span class="asterisk">*</span>
                    </label>
                    <input name="nombre" class="ss-q-short" id="formNombre" type="text">
                </div>
                <div class="caja">
                    <div class="flecha"></div>
                    <label class="tituloform" for="telefono">Teléfono
                    <span class="asterisk"></span>
                    </label>
                    <input name="telefono" class="ss-q-short" id="formTelefono" type="number">
                </div>
                <div class="caja">
                    <div class="flecha"></div>
                    <label class="tituloform" for="email">Mail
                    <span class="asterisk">*</span>
                    </label>
                    <input name="email" class="ss-q-short" id="formEmail" type="email">
                </div>
                <div class="caja">
                    <div class="flecha"></div>
                    <label class="tituloform" for="email">Fecha de Evento
                    <span class="asterisk"></span>
                    </label>
                    <input name="fecha" class="ss-q-short" id="formFecha" type="text">
                </div>
                <div class="caja">
                    <div class="flecha"></div>
                    <label class="tituloform" for="asunto">Asunto
                    </label>
                    <input name="asunto" class="ss-q-short" id="formAsunto" type="text">
                </div>
                </div>
                <div class="punteadolargo" id="contacto"></div>
              <div class="raya" id="contacto"></div>
                <img src="img/mensaje.jpg" class="mensajecinta">
              <div class="mensaje">
              <div class="caja">
                    <label class="tituloform" for="mensaje">
                    </label>
                    <textarea name="mensaje" class="ss-q-short" id="formMensaje" form="web"></textarea>
                </div>
                </div>
            <div id="webFormResult"></div>
            <div>
                <p style="text-align:center">
                <input type="submit" value="" class="submit" name"submit"/>
                </p>
            </div>
        </form>
            <script type="text/javascript" src="global.js"></script>

        <!--form-->
        </div>
</body>
</html>
在mail.php中删除@

$res = @mail('maiamaranghello@gmail.com', 'Contacto desde web', $msg, $header);
/

还要检查php.ini,确保SMTP正常工作,并且所需的端口(25)打开良好

我看到的一个问题是,在可见的代码中,没有在代码中包含jQuery库。首先尝试将其添加到代码中,看看它是如何工作的


此外,您可能希望删除Amir在其帖子中提到的@符号。

因为您提到了conent type set,头是text/json,可能您的浏览器配置为下载json而不是打开它。
您可能需要一个插件,以便在浏览器中看到它

哦,是的,您是对的,这就是问题所在,我可能会错误地删除它。谢谢有时有一个额外的视图来发现问题是很好的!
$(document).ready(function(){

    $('form#web').submit(function(){

        var definitions = [
        {
            id: 'formNombre',
            type: 'string',
            title: 'nombre'
        },

        {
            id: 'formEmail',
            type: 'email',
            title: 'email'
        },

        {
            id: 'formAsunto',
            type: 'string',
            title: 'asunto'
        },
        {
            id: 'formMensaje',
            type: 'string',
            title: 'mensaje'
        }       
        ];

        if( formValidar($(this), definitions) ) {

            console.log($(this));

            $.post('mail.php', $(this).serialize(), function(json){

                if(json.result == true) {
                    $('#webFormResult').html('El mensaje se ha enviado correctamente!');
                } else {
                    $('#webFormResult').html('No pudimos enviar el mensaje, intente nuevamente');
                }
                $("#web input[type=text],#web input[type=email], #web input[type=number], #web textarea, #web select").val('');

            });

            return false;

        } else {
            return false;
        }

    });
});
$res = @mail('maiamaranghello@gmail.com', 'Contacto desde web', $msg, $header);
$res = mail('maiamaranghello@gmail.com', 'Contacto desde web', $msg, $header);