Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/11/2010, 16:54
Avatar de mayid
mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: respuesta json fallida por ajax

Listo. Queda algo así: function (XMLHttpRequest, textStatus, errorThrown)

El primer parametro es un objeto. El segundo devuelve "error". El tercero dice "Invalid JSON: HO[{"status":1}]", donde "HO" es una cadena que imprimí para romper mi json y debuguear.

En mi caso:
Código Javascript:
Ver original
  1. // formularios ajax    
  2.     var options = {
  3.         success:   enviar,  // post-submit callback
  4.         error: manejoErrores,
  5.         dataType:  'json'      
  6.     };  
  7.    
  8.     $(".form form").ajaxForm(options);  // inicializacion
  9.    
  10.     function enviar(texto, status, xhr, $form){
  11.         alert(status);
  12.         if (texto[0].status == 1)
  13.             window.location.reload();
  14.         else
  15.         {
  16.             $("span.captcha img").attr("src", "<?php echo HTTP_APP; ?>utiles/captcha/captcha.php"+  '?' + (new Date()).getTime());
  17.             $(".mensajeError").css("display", "block").text(texto[0].texto);
  18.         }
  19.     }
  20.    
  21.     function manejoErrores(request, status, errorData)
  22.     {
  23.         alert(errorData);
  24.     }

Gracias!