Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/04/2012, 12:20
Avatar de Trublux
Trublux
 
Fecha de Ingreso: octubre-2010
Ubicación: Madrid
Mensajes: 355
Antigüedad: 13 años, 6 meses
Puntos: 48
Respuesta: jquery una function con un evento click y aplicar ajax

Mira la consola te debe estar dando errores porque le faltan algunos cierres de llaves/paréntesis y algunos puntos y comas.
Código Javascript:
Ver original
  1. var checkear = function(numero){
  2.     $('td').click(function(){
  3.         $.ajax({
  4.             type : 'POST',
  5.             url : 'checkear.php',
  6.             cache : false,
  7.             data : 'id=' + numero,
  8.             beforeSend : function(){
  9.                 $(this).html("sirve");
  10.             }, success: function(data){
  11.                 $(this).html("sirve");
  12.             }
  13.         });
  14.     });
  15. };

Aunque creo que sería mejor así (aunque deberías determinar qué es la variable "numero" y cambiar el "$(this)" en la función "checkear"):
Código Javascript:
Ver original
  1. var checkear = function( numero ){
  2.     $.ajax({
  3.         type : 'POST',
  4.         url : 'checkear.php',
  5.         cache : false,
  6.         data : 'id' ,
  7.         beforeSend : function(){
  8.             $(this).html("sirve");
  9.         }, success: function(data){
  10.             $(this).html("sirve");
  11.         }
  12.     });
  13. };
  14.  
  15. $(function(){
  16.     $( 'td' ).click( function(){
  17.         checkear( numero );
  18.     });
  19. });
__________________
eZ Publish Developer Basic Legacy
eZ Publish Developer Basics (4.4)
Alojamientos rurales en España

Última edición por Trublux; 20/04/2012 a las 12:27