Foros del Web » Programando para Internet » Jquery »

[SOLUCIONADO] Llamar a una función - ReferenceError: Can't find variable

Estas en el tema de Llamar a una función - ReferenceError: Can't find variable en el foro de Jquery en Foros del Web. Hola Estoy implementando en una web Joomla unas gráficas de Higcharts, y todo lo tengo ya listo, salvo que cuando quiero quiero llamar a la ...
  #1 (permalink)  
Antiguo 29/12/2014, 03:28
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Llamar a una función - ReferenceError: Can't find variable

Hola

Estoy implementando en una web Joomla unas gráficas de Higcharts, y todo lo tengo ya listo, salvo que cuando quiero quiero llamar a la función getAjaxDatat me dice el error ReferenceError: Can't find variable: getAjaxDatat



Código:
jQuery(function () {
		getAjaxDatat(24);
		jQuery('#data-temp').change(function(){
            var val = jQuery('#data-temp').val();
			getAjaxDatat(val);
        });
        
		jQuery(function getAjaxDatat(id){
			jQuery.getJSON('data-temp.php', {id: id}, jQuery(function(chartData) {
				Highcharts.setOptions({
					lang: {
						contextButtonTitle: 'Opciones',
					}
				});
  #2 (permalink)  
Antiguo 29/12/2014, 11:17
(Desactivado)
 
Fecha de Ingreso: abril-2013
Ubicación: rosario
Mensajes: 248
Antigüedad: 11 años
Puntos: 17
Respuesta: Llamar a una función - ReferenceError: Can't find variable

Pregunta, porque haces esto ? jQuery(function getAjaxDatat(id){
No podes hacerlo asi?

Código Javascript:
Ver original
  1. jQuery(function () {
  2.  
  3.     function getAjaxDatat(id){
  4.         jQuery.getJSON('data-temp.php', {id: id}, jQuery(function(chartData) {
  5.             Highcharts.setOptions({
  6.                 lang: {
  7.                 contextButtonTitle: 'Opciones',
  8.                 }
  9.             });
  10.         })
  11.     }  
  12.    
  13.  
  14.     getAjaxDatat(24);
  15.     jQuery('#data-temp').change(function(){
  16.         var val = jQuery('#data-temp').val();
  17.         getAjaxDatat(val);
  18.     });
  19.    
  20. });
  #3 (permalink)  
Antiguo 29/12/2014, 13:49
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Llamar a una función - ReferenceError: Can't find variable

¿Ponerlo después? Da igual, sigue saliendo el mismo error, pero lineas mas abajo. El problema está en la declaración al llamar a la función que no es así, y no se realmente que hay que poner
  #4 (permalink)  
Antiguo 29/12/2014, 14:01
(Desactivado)
 
Fecha de Ingreso: abril-2013
Ubicación: rosario
Mensajes: 248
Antigüedad: 11 años
Puntos: 17
Respuesta: Llamar a una función - ReferenceError: Can't find variable

Tenes el sitio on line? para poder reproducir el error
  #5 (permalink)  
Antiguo 29/12/2014, 14:03
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Llamar a una función - ReferenceError: Can't find variable

el que no está incrustado en joomla si:

www.renuncio.com/beta2
  #6 (permalink)  
Antiguo 29/12/2014, 14:05
(Desactivado)
 
Fecha de Ingreso: enero-2013
Mensajes: 289
Antigüedad: 11 años, 2 meses
Puntos: 10
Respuesta: Llamar a una función - ReferenceError: Can't find variable

has probado de poner el código de jquery dentro de $(document).ready ?
  #7 (permalink)  
Antiguo 29/12/2014, 14:12
(Desactivado)
 
Fecha de Ingreso: abril-2013
Ubicación: rosario
Mensajes: 248
Antigüedad: 11 años
Puntos: 17
Respuesta: Llamar a una función - ReferenceError: Can't find variable

no lo probaste como yo te lo pase, es decir asi:

Código Javascript:
Ver original
  1. [B]function getAjaxDatat(id){
  2.         jQuery.getJSON('data-temp.php', {id: id}, jQuery(function(chartData) {
  3.             Highcharts.setOptions({
  4.                 lang: {
  5.                 contextButtonTitle: 'Opciones',
  6.                 }
  7.             });
  8.         })
  9.     }   [/B]

y no asi

Código Javascript:
Ver original
  1. jQuery(function getAjaxDatat(id){

Asi, le estas diciendo q llame a un metodo dentro de jquery llamado getAjaxDatat, pero este no existe.
Probalo y me avisas.
  #8 (permalink)  
Antiguo 29/12/2014, 14:20
(Desactivado)
 
Fecha de Ingreso: abril-2013
Ubicación: rosario
Mensajes: 248
Antigüedad: 11 años
Puntos: 17
Respuesta: Llamar a una función - ReferenceError: Can't find variable

En esta linea tambien te va a dar error

jQuery.getJSON('data-temp.php', {id: id}, jQuery(function(chartData) {
  #9 (permalink)  
Antiguo 29/12/2014, 16:10
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Llamar a una función - ReferenceError: Can't find variable

diurno10 de esa forma no funciona tampoco

en www.renuncio.com/beta1/meteorologia/meteorologia-actual se puede ver integrado con joomla.

El código original y que me funcionaba era este:

Código:
$(function () {
		
	getAjaxDatat(24);
        
	$('#data-hume').change(function(){
            var val = $('#data-hume').val();
			getAjaxDatat(val);
        });
		
		function getAjaxDatat(id){		
			$.getJSON('data-hume.php', {id: id}, function(chartData) {
				Highcharts.setOptions({
					lang: {
						contextButtonTitle: 'Opciones',
					}
				});
				$('#container-hume').highcharts({

Pero al meterlo en joomla para que no hubiera conflictos, tuve que reemplazar los $ por jQuery


Código:
jQuery(function () {
	getAjaxDatat(24);
	jQuery('#data-hume').change(function(){
            var val = jQuery('#data-hume').val();
			getAjaxDatat(val);
        });
        
		jQuery(function getAjaxDatat(id){
			jQuery.getJSON('data-hume.php', {id: id}, jQuery(function(chartData) {
				Highcharts.setOptions({
					lang: {
						contextButtonTitle: 'Opciones',
					}
				});
				jQuery('#container-hume').highcharts({
  #10 (permalink)  
Antiguo 30/12/2014, 06:40
(Desactivado)
 
Fecha de Ingreso: abril-2013
Ubicación: rosario
Mensajes: 248
Antigüedad: 11 años
Puntos: 17
Respuesta: Llamar a una función - ReferenceError: Can't find variable

Estamos de acuerdo con lo que haces para que no entre en conflicto la libreria, es mas, es una buena practica manejarlo asi, pero lo que quiero que me expliques es por que haces esto?

jQuery(function getAjaxDatat(id){

y no esto

function getAjaxDatat(id){

Ahhh y no olvides en javascript las funciones se declaran antes de utilizarlas, es decir:

function getData(param){

}

getData(5);
  #11 (permalink)  
Antiguo 30/12/2014, 07:32
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Llamar a una función - ReferenceError: Can't find variable

Pues porque como sin ello me daba error, y probé a ver si así no había error.

Cita:
jQuery(function () {

function getAjaxDatat(id){};
getAjaxDatat(24);
jQuery('#data-temp').change(function(){
var val = jQuery('#data-temp').val();
getAjaxDatat(val);
});

function getAjaxDatat(id){
jQuery.getJSON('data-temp.php', {id: id}, function(chartData) {
Highcharts.setOptions({
lang: {
contextButtonTitle: 'Opciones',
}
});
jQuery('#container-temp').highcharts({
Estando así, me funciona fuera de joomla, dentro de joomla me sigue dando error. Imagino que hay algún conflicto pero estoy desesperado porque no lo veo.

Última edición por rpm32; 31/12/2014 a las 08:40
  #12 (permalink)  
Antiguo 31/12/2014, 08:47
 
Fecha de Ingreso: diciembre-2014
Mensajes: 6
Antigüedad: 9 años, 3 meses
Puntos: 0
Respuesta: Llamar a una función - ReferenceError: Can't find variable

Bueno, pues por fin, lo conseguí :

Cita:
jQuery(function () {

function getAjaxDatat(id){};
getAjaxDatat(24);

jQuery('#data-temp').change(function(){
var val =jQuery ('#data-temp').val();
getAjaxDatat(val);
});
function getAjaxDatat(id){
jQuery.getJSON('data-temp.php', {id: id}, function(chartData){

Gracias por las respuestas

Etiquetas: find, variable
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:50.