jquery - Ajax request will scroll to the top after success. -
get_queue_data() gets called every 10 secs, calls ajax query every 10 sec. issue each time after ajax call gets called, page scrolls top. of solutions online tell me use preventeventdefault. tried passing variable function get_queue_data, , tried calling preventeventdefault. still doesn't work. tried returning false get_queue_data function.
get_queue_data(); setinterval(get_queue_data,10000); function get_queue_data() { $.ajax({ url: '/a/order/order_process/all_queues_data', datatype: 'json', async: true, success: function (data) { for(var k=0;k<22;k++) { chart.series[k].addpoint([data.all_queues_data[k]['messages']]); var temp_series = chart.series[k]; average_chart_data[k] = (temp_series.data[temp_series.data.length-1].y+(average_chart_data[k]*(temp_series.data.length-1)))/(temp_series.data.length); } //console.log(average_chart_data, last_value_chart_data); $('#queue_report').highcharts({ chart: { height : 500, margin :50, width: $('#queue_data').width(), events: { load: function () { function create_label(message, x, y, fill_color, link) { ren.label(message, x, y) .attr({ fill: fill_color, stroke: 'white', 'stroke-width': 2, padding: 5, cursor: 'pointer', r: 5 }) .on('click', function () { var win = window.open(link, '_blank'); win.focus(); }) .add(data.all_queues_data[0][0]) .shadow(true); } } } }); } }); }
the redraw of chart replaces dom element causing it's height 0 moment.
Comments
Post a Comment