PHP don't return number by jquery ajax -


i unable solve problem , have no idea i'm doing wrong

i got php file called gettotalprotocolobyfilter.php

<?php       require_once(dirname(__file__).'/../datos/conexionmssql.class.php');        try {         $conexionmssql = conexionmssql::getinstance();          $query="select count(1) total protocolos_web_new tipo = ".$_post['tipo'];          $conexionmssql->abrir('ingcer_bd');         $result = $conexionmssql->consulta($query);         $conexionmssql->cerrar();         $total=new stdclass();          while ($row = mssql_fetch_object($result)) {           echo json_encode($row->total);         }        } catch (exception $e) {         error_log($e->getmessage());       } ?> 

and js function:

var gettotalprotocolosbyfilter = function(filter){   total=0;   $.ajax({     url: '/protected/functions/gettotalprotocolosbyfilter.php',     type: 'post',     async:false,     datatype: 'json',     data: filter,     success: function(response){       total=response;     }   })   .done(function() {     console.log("success");   })   .fail(function() {     console.log("error");   })   .always(function() {     console.log("complete");   });   return total; }// fin gettotalprotocolosbyfilter 

and don't nothing on ajax response, if change echo json_encode($row->total); echo json_encode("".$row->total);

i got: 0:"1"

1:"4"

2:"2"

on top number echo, bottom string echo

on top number echo, bottom string echo

thanks


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -