diff --git a/public/index.html b/public/index.html index 8e28c4f..a289c72 100644 --- a/public/index.html +++ b/public/index.html @@ -8,10 +8,34 @@ if (form[i].name) items[form[i].name] = form[i].value } - console.log(items) + var params = "?" + for(var k in items) { + params += k + "=" + items[k] + "&" + } + params = params.substr(0, params.length-1) + http("GET", "http://localhost:18114/who" + params, function(body, status) { + console.log(status, "body=",body) + }, null) return false; } + function http(method, remote, callback, body) { + var xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { + console.log("KK", xmlhttp.readyState, xmlhttp.responseText, xmlhttp.status) + callback(xmlhttp.responseText, xmlhttp.status) + } + }; + xmlhttp.open(method, remote, true); + if (typeof body == "undefined") { + body = null + } + xmlhttp.send(body); + } + function callback(responseBody, responseStatus) { + } + function draw(one) { var id = one.id var meta = one.meta diff --git a/view/html.go b/view/html.go index 3d44e55..e6dce1f 100644 --- a/view/html.go +++ b/view/html.go @@ -5,6 +5,7 @@ import ( "fmt" "local/whodunit/config" "local/whodunit/storage" + "log" "net/http" ) @@ -37,9 +38,10 @@ func who(g storage.Graph, w http.ResponseWriter, r *http.Request) error { return err } if len(ones) != 1 { - ones = nil + ones = append(ones, storage.One{}) } results[id] = ones[0] } + log.Println("results:", results) return json.NewEncoder(w).Encode(results) }