Pregunta

En la función Chrome pero en IE10 se devuelve un error para el nombre de la variable en la función, ¿cómo puedo tener acceso a esta variable desde la función?

  $('.kpit').on('click', function() {        
        var url = $(this).attr('id');
        var name = $(this).attr('href');
        $('.kpi').html('');
        $.post(url, {idKpi: id}, function(result) {
            $(name).html(result);
        });
  });
¿Fue útil?

Solución

Intentar:

 $('.kpit').on('click', function() {        
        var name = $(this).attr('id');
        var element = $(this); //Removed the .attr('href'), as that would store the URL, not the element.

        $('.kpi').html('');
        $.post(name, {idKpi: id}, function(result) {

        $(element).attr('href',result); //Set the HREF by using .attr, not .html
        });
  });

Ver Establecer el atributo href en tiempo de ejecución

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top