Success : Function ajax call another javascript function

Asked

Viewed 937 times

1

function paginacao_tabela_clientes_status(idpessoa){
  $.ajax
        ({
            type: 'POST',
            dataType: 'json',
            url: BASE_URL + '/clients/tabela_clientes_pedido_entregue',
            data: {idpessoa: idpessoa},
            success: function (msg)
            {
                var aoColumns = [{"data": "nomedesc"},
                    {"data": "id_pedido"},
                    {"data": "ped_representante"},
                    {"data": "num_sofa"},
                    {"data": "qtde"},
                    {"data": "totalpedido", render: $.fn.dataTable.render.number('.', ',', 2, 'R$ ')}];
                datatable('#table_pedido_entregue', msg, aoColumns);
            }});

clientsController.php function of ajax url

    public function tabela_clientes_pedido_entregue() {
    $idpessoa = addslashes($_POST['idpessoa']);
    $cli = new Clients;
    $cli->tabela_clientes_pedido_entregue($idpessoa);
}

function of the Clients.php model

 function tabela_clientes_pedido_entregue($idpessoa) {
    $sql = $this->db->prepare("SELECT 
    `pedido`.`id` AS `id_pedido`,
    pedido.ped_representante,
    itempedido.num_sofa as num_sofa,
    itempedido.nomedesc as nomedesc,
    concat(itempedido.qtde_entregue,'/', itempedido.qtde_solicitada)as qtde,
     SUM(itempedido.qtde_entregue * `itempedido`.`vlr_unitario`)  AS `totalpedido`      
    FROM `pedido`
    JOIN `pessoa` ON (`pedido`.`idcliente` = `pessoa`.`id`)
JOIN `itempedido` ON (pedido.id = `itempedido`.`idpedido`)
    WHERE ((itempedido.qtde_solicitada - itempedido.qtde_entregue)= 0
    or (itempedido.qtde_solicitada - itempedido.qtde_entregue)< itempedido.qtde_solicitada )
    and pedido.idcliente = :idpessoa
    group by pedido.id, pedido.ped_representante,itempedido.num_sofa");
    $sql->bindValue(":idpessoa", $idpessoa);
    $sql->execute();
    $json = array();
    while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
        $json[] = $row;
    }
    echo json_encode($json);
}

here and function in javascript that is in the call_data_tables.js of the error when it is called

function datatable(tabela, json, data) {
$(tabela).dataTable(
        {
            "aaData": json,
            "aoColumns": data,
            "language": {
                "sEmptyTable": "Nenhum registro encontrado",
                "sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
                "sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
                "sInfoFiltered": "(Filtrados de _MAX_ registros)",
                "sInfoPostFix": "",
                "sInfoThousands": ".",
                "sLengthMenu": "_MENU_  Resultados por Página",
                "sLoadingRecords": "Carregando...",
                "sProcessing": "Processando...",
                "sZeroRecords": "Nenhum registro encontrado",
                "sSearch": "Pesquisar",
                "oPaginate": {
                    "sNext": "Próximo",
                    "sPrevious": "Anterior",
                    "sFirst": "Primeiro",
                    "sLast": "Último"
                },
                "oAria": {
                    "sSortAscending": ": Ordenar colunas de forma ascendente",
                    "sSortDescending": ": Ordenar colunas de forma descendente"
                }
            }
        }
);};

on the local server it recognizes normal put the links

<script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/js/chama_dataTables.js"></script>

<script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/js/paginacao_tabela_clientes_status.js"></script>

at home, but on the web server it recognizes the normal paginacao_tabela_clientes_status.js file and I call the function datatable('#table_pedido_delivered', msg, aoColumns); but the server does not recognize, appears in the error


Fatal error: Class 'assetsController' not found in /home/marciavarais/public_html/core/core . php online 39
the server reads as if it were view

this and status view it opens from the view clients in _Blank

<h1><center>Status</center></h1>
<h2>Cliente: <?php echo $client_info[0]['id'] ?> - <?php echo     $client_info[0]['nomedesc'] ?> </h2>
<script type="text/javascript">
var BASE_URL = "<?php echo BASE_URL; ?>";
window.onload = function () {
paginacao_tabela_clientes_status(<?php echo $client_info[0]['id']; ?>);
};
</script>
<div class="tabarea">
<div id="id_form_0" class="tabitemdespesa activetab">Pedidos</div>
<div id="id_form_1" class="tabitemdespesa ">Carga</div>
<div id="id_form_2" class="tabitemdespesa">Conta a Receber ( em  Desenvolvimento)</div>
</div>
<div class="tabcontent">
<div class="tabbody" style="display:block">
    <h3><center>Pedidos entregue</center></h3>
    <table cellspacing="0" border="0" width="100%"   id="table_pedido_entregue"  class="display">
        <thead>  
            <tr>
                <th width="40%" class="select-filter">Descrição  Produto</th>
                <th width="10%"class="select-filter">Nº pedido</th>
                <th width="10%"class="select-filter">Nº ped. repres.</th>
                <th width="10%" class="select-filter">Num_Sofa</th>
                <th width="10%"class="select-filter">Quantidade</th>
                <th width="30%"class="select-filter">Valor Total</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
    </div>
    </div>
    <link href="<?php echo BASE_URL; ?>/assets/css/cliente_status.css" rel="stylesheet" />

    <script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/js/jquery-1.12.4.js"></script>

    <link rel="stylesheet" href="<?php echo BASE_URL; ?>/assets/DataTables/datatables.min.css"/>

    <script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/DataTables/datatables.min.js"></script>

    <script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/js/chama_dataTables.js"></script>

    <script type="text/javascript" src="<?php echo BASE_URL; ?>/assets/js/paginacao_tabela_clientes_status.js"></script>

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
#RewriteRule ^(.*)$ /baseflex/index.php?q=$1 [QSA,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Este domínio herda o pacote “PHP”.
# php -- END cPanel-generated handler, do not edit

logs_erros_php

[01-Oct-2017 01:35:46 America/Sao_Paulo] PHP Fatal error:  Uncaught Error: Class 'assetsController' not found in /home/marciavarais/public_html/core/core.php:39
Stack trace:
#0 /home/marciavarais/public_html/index.php(44): core->run()
#1 {main}
thrown in /home/marciavarais/public_html/core/core.php on line 39

depends on which code has php in the view in the ajax request you put it up there someone knows what it might be?

  • 1

    This seems more error in PHP than in Javascript. Can [Edit] the question and add PHP code? What would that be assetsController?

  • there is no assetsController, the server is reading the javascript link as if it were in the browser url, and the php code

  • Got it. So your file .htaccess must be wrong, not directly serving the static files. Can you put his code in the question? And is using some framework or the application was developed from scratch?

  • was from scratch, framework the problem and maintenance, I finished college and always used c# for desktop, to start with web, but I like to create the structure halfway renders more, vo picks code and already put

  • The directory assets exists at the root of the project?

  • exists, structure, asses/js/os scripts, only from the error on the web server should htaccess itself, you saw there

  • In my view, the application is not able to correctly identify any static file, which possibly does not exist, and analyzing the request with PHP. Since PHP expects the first URL value to be the controller, it tries to run assetsController, generating the error presented. It remains to know exactly which is the file that this occurs. PHP does not generate any type of log?

  • the rest of the project ta normal, because I call a javascript.js and use the functions that are inside it, but in this case I call a function of another javascript.js ai from the fire debug error <code>Syntaxerror: expected Expression, got '<' <br /> chama_d...bles.js (line 1) ReferenceError: datatable is not defined paginac...atus.js (linha 18, col 21) ReferenceError: datatable is not defined paginac...atus.js (linha 34, col 21) ReferenceError: convertedate is not defined paginac...atus.js (linha 46, col 49) Referenceerror: convertedate is not defined paginac...atus.js (line 61, col 49) <code>

Show 3 more comments
No answers

Browser other questions tagged

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