When I made the application it worked great. I create a graph of highCharts based on several queries to the database and I assemble it with PHP. This is called by means of an AJAX, this is the ajax:
//TRAEMOS LA INFORMACIÓN CUANDO SE DA CLICK EN JUSTIFICACIONES
$(document).on('click', '#justifica', function(e)
{
e.preventDefault();
//Borramos el elemento que tiene una gráfica.
$('#chart_script').remove();
//limpiamos el div que se llenará con los datos
$('#response').html("");
//llamada a AJAX
$.ajax({
url: 'php/control_administrativo/justificaciones_form.php',
method: 'POST',
success: function(data)
{
//cuando regresa la información la metemos en el reponse y
//le damos formato de Datatable a la tabla
$('#response').html(data);
$('#tabla_justificaciones').DataTable({
"scrollY": "250px",
"paging": true
});
//De nuevo una llamada a AJAX
$.ajax({
url:'php/control_administrativo/justificacion_chart.php',
method:'POST',
success:function(chart)
{
//Si responde PHP con una X no mostrar nada.
if (chart=="X")
{
$('#chart').html('');
}
else
{
//Creamos el tag con javascript
var script=document.createElement('script');
script.type='text/javascript';
script.id='chart_script';
$("body").append(script);
//le asignamos la información que se armó en PHP
$('#chart_script').html(chart);
//triggereamos el chart para que se muestre
show_chart();
}
}
});
}
});
});
The problem comes here. AJAX answers the information correctly:
In fact, if I copy the code that returns AJAX to me and I open it in a new document, the graphic appears:
This graph has 4 levels of drilldown, about 11 thousand lines of code, which is not a problem. The problem comes here. After 3 seconds AJAX gives me the answer but I get an error. First of all, the code I created is badly prepared and in the end you can not find the trigger to launch the chart
If I click on the VM error it gives me the Sources tab and this appears:
As if the script had not been formed correctly, but PHP and AJAX are responding to me completely. I want to assume that it is an error or that it has something to do with the browser, I do not know. Maybe a problem with the browser cache or something is happening. The funny thing is that it does not happen in all the machines, sometimes if it appears complete with other users and not with others.
I have not the slightest idea that can happen. Thanks.