Problem with AJAX WEB environment

Asked

Viewed 51 times

0

Good afternoon. I have an application on localhost this working perfectly, but the WEB does not follow picture:

LocalhostLocalhost

WEB WEB

The list of products in this case is large, and in the web works when I select only half of the list, in the latter does not work, I pass this data by ajax and do the validation by isset() to check if was selected some line, follows the ajax function:

<script>
        $(document).ready(function(){
            $('#pedido').submit(function(){     //Ao submeter formulário
                confirma = confirm("Confirma geração do pedido?");
                if(confirma){   
                    $.ajax({            //Função AJAX
                        url:"gerarPedido.php",          //Arquivo php
                        type:"post",                //Método de envio
                        beforeSend: function(){ $("#btnSalvar").val('Aguarde...');},
                        data: $('#pedido').serialize(), //Dados
                            success: function (resposta){           //Sucesso no AJAX
                                $("#error").slideDown();
                                    if (resposta != false) {
                                         // Exibe o erro na div
                                        $("#error").html(resposta);
                                        $("#btnSalvar").val('Gerar Pedido');
                                    }else {
                                     // Exibe mensagem de sucesso
                                    // $("#error").html("<div class='col-lg-6 col-md-6 col-sm-6 col-xs-6 alert alert-success alert-dismissable'><i class='fa fa-check'></i>     <button type='button' class='close' data-dismiss='alert' aria-hidden='true'><i class='fa fa-times-circle'></i></button>O cadastro foi salvo com sucesso!</div>");
                                     $("#btnSalvar").val('Gerar Pedido');
                                    }

                            }

                    })                  
                    return false;   //Evita que a página seja atualizada
                }
                    return false;   //Evita que a página seja atualizada
            })
        })
 </script>

Only the WEB server is not working. PHP Localhost Version: 5.3.1 PHP version Web server: 5.3.28

PHP code

if(isset($_POST['selecao'])){
    foreach($_POST['selecao'] AS $key => $value){
        /*echo $value.'<br/>';*/
        $qtd = $_POST['qtd'][$value];
        $valor = $_POST['valor'][$value];
        $preco = str_replace(',', '.', $valor);
        $preco_bruto = $qtd * $valor;
        if(empty($qtd)){
            echo "Informe a quantidade para o produto ".$_POST['descricao'][$value]."";
            exit;
        }
        if(empty($preco) || ($preco == 0)){
            echo "Informe o valor do produto ".$_POST['descricao'][$value]."";
            exit;
        }

    }

}Else{ echo 'Select at least one product'; }

  • Error appears?

  • Ain’t no mistake there.

  • can you receive the post? from a print_r on it and from a console.log on the return of the ajax.

  • do not receive the post because I do a check with isset().

  • Enter the php code

  • I no longer know what to do, there are 137 items in the list, any line that selects after line 111 does not go through ajax, and only on the WEB server on localhost is no problem

  • 1

    It may be that the server is limiting the size of the post.

  • but I am sending as array, and what would be the solution to this?

  • I noticed that in the server the post_max_size this 64M and local 128M could be this?

  • It may be if the processing uses memory method, so you need to check the error in the log or enable them.

  • and how do I increase the post_max_size already tried by . htaccess and did not work

Show 6 more comments
No answers

Browser other questions tagged

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