Question

this is my first question in a forum ever i think ;-). I will try to be as clear as possible with the question.

I´m trying to build a visual traceroute similar to that on yougetsignal.com by kirk ouimet.

It is actually working already using bash (traceroute,ping,host,) php/javascript, but I´m having some trouble with Javascript/AJAX.

Kirk updates the traced host-list periodically or via some kind of ajax-interrupt on the right side of the trace. I only know how to do it in one pass with one single Javascript xmlhttp-call and then echo a table into a standard w3school-livesearch-DIV.

http://www.yougetsignal.com/tools/visual-tracert/

I also don´t know if he does the traceroute with a cmd-line-tool like linux´s "traceroute". Mine is working fine by first tracerouting, then doing reverse-lookup using "host" and then pinging all hosts in the list again to get the rrt.

Is there any way to poll a txt-file (the traces) and then echo the output on demand to a DIV?

I´m grateful for any hint.

Stefan

p.s.: the google-maps plotting works fine, it´s about the process of updating the traced-hosts on demand for users (and me) to enjoy.

Was it helpful?

Solution

What you can do by using jQuery for ajax calls:

setInterval(function () {
    $('#yourdiv').load('http://domain.com/yourfile');
}, 30000);

This code will load pregenerated html content to a specified div container every 30s. If you don't what to load a temporary generated html/php content, you can build an API and then add the data comming back dynamically on the DOM every time.

setInterval(function () {
    $.getJSON('yourAPIUrl', function (data) {
        $.each(data, function (item) {
            // do something with the retrieved data, add it to the DOM for example
        }
    });
}, 30000);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top