Error 0 while sending message by Ajax

Asked

Viewed 100 times

0

I have a system of posts in PHP and Jquery, where users post things. It hasn’t been released to anyone yet, for I want to get everything ready, but I came across an error that is happening in the system.

When I’m at home it works normally, but when I go on an internet with a weaker power, it gives the following error:

Error 0 - error Error Type: error

Sometimes it sends the message and sometimes not, and even then the error happens.

PHP

$data = date('d/m/Y')." ".date('H:i:s');

$dia = date('d/m/Y');
$hora = date('H:i:s');

$horac = date('d/m/Y')." ".date('H:i:s');

$frase = addslashes($_POST['texto']);

$tipo = "1";

$query = "insert into postagens(texto, id_user, data, hora, horat, horac, tipo) values ('$frase','$usuario_id','$dia','$hora','$data','$horac','$tipo')";
$rs = $mysqli->query($query);

FOLLOW THE JQUERY CODE:

$(document).ready(function() {
    var iconCarregando = $('carregando');
    $('#form').submit(function(e) {
        if ($("#texto").val() == '') {
            $('#texto').select();
            return false;
        } else {
            e.preventDefault();
            var serializeDados = $('#form').serialize();

            $.ajax({
                url: 'acoes.php?enviar=1',
                dataType: 'html',
                type: 'POST',
                data: serializeDados,
                beforeSend: function() {
                    $('#result').html(iconCarregando);
                    $('#send').attr('disabled', 'disabled'); //desabilito
                },
                complete: function() {

                },
                success: function(data, textStatus) {

                    $('#texto').val("");
                    $('#send').removeAttr('disabled'); //habilito


                    $("#success-alert").alert();
                    $("#success-alert").fadeTo(2000, 400).slideUp(400, function() {
                        $("#success-alert").slideUp(400);
                    });

                },
                error: function(xhr, er) {
                    $('#form').html('<p class="destaque">Error ' + xhr.status + ' - ' + xhr.statusText + '<br />Tipo de erro: ' + er + '</p>')
                }
            });

        }

    });
});
  • Talk to the guy, okay? There’s a way you can put the PHP code too so people can better analyze what’s happening on the server-side?

  • friend is just a form with textarea, very straight...

  • I refer to the acoes.php file

  • put the file

  • Could be timeout, error falls here error: function(xhr, er) { right?

  • yeah, what is that?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.