$. ajax - POST ..... 500 (Internal Server Error)

Asked

Viewed 3,777 times

1

I am sending a request to a URL by function $.ajax() and I need you to return to me one of the parameters (was, error, Nothing). In the localhost is working correctly, put on the server and returns POST http://www.clickbankonline.com.br/backoffice/insertFila 500 (Internal Server Error).

I click on a button and make the JS request in this code:

$.ajax({
                url: baseURL+'backoffice/insertFila', 
                data: {bandeira:bandeira,conta:conta,agencia:agencia,tipo:tipo,titular:titular,cpf:cpf,skf:skf},
                type: 'POST',
                success: function(callback){


                    if(callback == 'nothing'){

                        $("#retorno").html('<div class="alert alert-info" align="center"><b>Atenção:</b> Não existe nenhum usuário na fila que você escolheu, por favor, tente mudar a bandeira ou a fila para se cadastrar e entrar em uma fila.</div>');
                        $('html, body').animate({scrollTop:0}, '2000');

                    }else{

                        if(callback == 'foi'){

                        $("#btn-cadastroFila").prop('disabled', true);
                        $("#retorno").html('<div class="alert alert-success" align="center">Você foi cadastrado na fila, aguarde enquanto redirecionamos você.</div>');
                        $('html, body').animate({scrollTop:0}, '2000');

                        }else{

                        $("#retorno").html('<div class="alert alert-info" align="center"><b>Alerta:</b> Não foi possível cadastrar sua conta em nossa fila. Entre em contato com nosso suporte para resolvermos seu problema.<br />Erro: '+callback+'</div>');
                        $('html, body').animate({scrollTop:0}, '2000');

                        }

                    }
                }

            });

And call the URL http://www.clickbankonline.com.br/backoffice/insertFila containing the code:

public function insertFila(){

        $bandeira = $this->input->post('bandeira');
        $conta = $this->input->post('conta');
        $agencia = $this->input->post('agencia');
        $tipo = $this->input->post('tipo');
        $titular = $this->input->post('titular');
        $cpf = $this->input->post('cpf');
        $skf = $this->input->post('skf'); //IDFila

        $this->db->where('id_usuario', $this->session->userdata('user_id'));
        $this->db->where('fila', $skf);
        $this->db->where('liberado', 1);
        $this->db->where('usado', 0);
        $this->db->where('retroalimentacao', 1);
        $this->db->order_by('id', 'DESC');

        $retroalimentacao = $this->db->get('sistema');

        if($retroalimentacao->num_rows() <= 0){

            $userID = $this->session->userdata('user_id');


            $queryCheck = $this->db->query("SELECT * FROM fila WHERE id_fila = '$skf' AND id_bandeira = '$bandeira' AND liberado = '1' AND doacoes < '2' ORDER BY id ASC LIMIT 1");

            if($queryCheck->num_rows() > 0){

            $rowReceptor = $queryCheck->row();

            $Doacoes = $rowReceptor->doacoes+1;
            $IDReceptorFila = $rowReceptor->id;
            $IDReceptor = $rowReceptor->id_usuario;

            $this->db->where('id', $IDReceptorFila);
            $Refresh = $this->db->update('fila', array('doacoes'=>$Doacoes));

                if($Refresh){

                    $this->db->where('id_indicado', $this->session->userdata('user_id'));
                    $dataReferencia = $this->db->get('referencia');

                    if($dataReferencia->num_rows() > 0){

                        $this->db->where('id_indicado', $this->session->userdata('user_id'));
                        $this->db->where('doacao', '0');

                        $this->db->update('referencia', array('doacao'=>'1'));
                    }

                    $isFila = $this->db->insert('fila', array('id_usuario'=>$userID, 'id_bandeira'=>$bandeira, 'id_fila'=>$skf, 'agencia'=>$agencia, 'conta'=>$conta,'tipo'=>$tipo,'titular'=>$titular,'cpf'=>$cpf, 'liberado'=>'0', 'doacoes'=>'0'));
                    $IDFilaInsert = $this->db->insert_id();

                    $Insert = $this->db->insert('pendentes', array('id_doador'=>$userID, 'id_receptor'=>$IDReceptor, 'id_fila'=>$IDFilaInsert, 'id_fila_receptor'=>$IDReceptorFila, 'pago'=>'0', 'tempo'=>(time() + 1800)));

                    $this->db->where('id_usuario', $userID);
                    $this->db->update('sistema', array('usado'=>1));

                    $this->db->where('id', $this->session->userdata('user_id'));
                    $cadastroCheck = $this->db->get('cadastros');

                    //enviarSMS('Voce acabou de se cadastrar na fila da ClickBank, agora va ate o menu Doacoes Pendentes e faca sua doacao', $cadastroCheck->row()->celular, $cadastroCheck->row()->mensagem);

                    if($Insert && $isFila){

                        echo 'foi';
                    }else{
                        echo 'error';
                    }
                }

            }else{

                echo 'nothing';
            }

        }else{

            //Caso for de retroalimentação

            $userID = $this->session->userdata('user_id');


            $queryCheck = $this->db->query("SELECT * FROM fila WHERE id_fila = '1' AND id_bandeira = '$bandeira' AND liberado = '1' AND doacoes < '2' ORDER BY id ASC LIMIT 1");

            if($queryCheck->num_rows() > 0){

            $rowReceptor = $queryCheck->row();

            $Doacoes = $rowReceptor->doacoes+1;
            $IDReceptorFila = $rowReceptor->id;
            $IDReceptor = $rowReceptor->id_usuario;

            $this->db->where('id', $IDReceptorFila);
            $Refresh = $this->db->update('fila', array('doacoes'=>$Doacoes));

                if($Refresh){

                    $isFila = $this->db->insert('fila', array('id_usuario'=>$userID, 'id_bandeira'=>$bandeira, 'id_fila'=>$skf, 'agencia'=>$agencia, 'conta'=>$conta,'tipo'=>$tipo,'titular'=>$titular,'cpf'=>$cpf, 'liberado'=>'0', 'doacoes'=>'0'));
                    $IDFilaInsert = $this->db->insert_id();

                    $Insert = $this->db->insert('pendentes', array('id_doador'=>$userID, 'id_receptor'=>$IDReceptor, 'id_fila'=>$IDFilaInsert, 'id_fila_receptor'=>$IDReceptorFila, 'pago'=>'0', 'tempo'=>(time() + 1800), 'retroalimentacao'=>1));

                    $this->db->where('id_usuario', $userID);
                    $this->db->update('sistema', array('usado'=>1));

                    $this->db->where('id', $this->session->userdata('user_id'));
                    $cadastroCheck = $this->db->get('cadastros');


                    if($Insert && $isFila){

                        echo 'foi';
                    }else{
                        echo 'error';
                    }
                }

            }else{

                echo 'nothing';
            }

        }
    }
  • You can look in the browser console (F12 - Chrome) go to the network tab, search and click on the page where the Internal Server Error occurred and see exactly what the error was...

  • Error 500 is from the server see or enable php error messages.

  • In PHP there is no error, so I ran the link normally.

  • Remote Address:198.24.156.58:80 Request URL:http://www.clickbankonline.com.br/backoffice/insertFila Request Method:POST Status Code:500 Internal Server Error flag:8 account:53367 agencia:-- type:Prepaid Account&#Xa holder:123 Cpf:31 skf:1 Connection:close Content-Length:477 Content-Type:text/html @Rafaelwithoeft

  • @Alissonacioli Did you run "ajax" and left the network tab open? When running the ajax will appear to you in the network tab... after clicking on the link that gave the Internal server error... in the other preview tab inside the link, you can see the stack trace of the error; it showed no error there?

  • @Rafaelwithoeft inside the network->Preview tab appears only one error page HTTP 500

  • Then there is no code error. If it were, something like: PHP Notice 'Yii base Errorexception' with message 'Undefined variable: return123'

  • The problem is that locally it works normally

  • @Alissonacioli already looked at the apache logs?

  • 1

    Is the php version the same on both servers? o ini_set('display_errors', true) and the error_reporting(E_ALL) you put it on the blank page.

  • 2

    @rray tidied up, the problem was the name of a table that was wrong. Thank you!

  • @Alissonacioli If possible post a reply explaining how you solved the problem and then mark it as accepted. :)

  • The error was the table name that was wrong in SELECT and returned the above errors.

Show 8 more comments
No answers

Browser other questions tagged

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