   onexec: (f) -> @addEventListener 'execText', f
 
 window.KDB ?= {}
+KDB.processJSONP = (id,res) ->
+  console.log "kdb-srv(JSONP): #{id}" + res if @debug
+  jsonpRegistry[id]?(res)
 KDB.KDBChart = document.registerElement('kdb-chart', prototype: _KDBChart.prototype)
 KDB.KDBSrv = document.registerElement('kdb-srv', prototype: _KDBSrv.prototype)
 KDB.KDBQuery = document.registerElement('kdb-query', prototype: _KDBQuery.prototype)

    @hidden = true
    @ws = @wsReq = null
    @wsQueue = []
    console.log "kdb-srv inited: srvType:#{@srvType}, target:#{@target}, prefix:#{@qPrefix}, rType:#{@rType}" if @debug
    if @target
      @target = (document.querySelector "[k-id='#{@target}']") || @target
  runQuery: (q,cb) ->
    (cb = (r,e) -> null) unless cb
    return @sendHTTP q,cb if @srvType is 'http'
    @sendWS q,cb
  sendWS: (qq,clb) ->
    @wsQueue.push q:qq, cb:clb

  sendHTTP: (q,cb) ->
    if @fixJson
      @fixJson = null
      @qPrefix = (if @srvType is 'jsonp' then 'jsp?' else "jsn?enlist ") unless @qPrefix
      query = ".h.tx[`jsn]:(.j.j');"
      query = '.h.tx[`jsp]:{enlist "KDB.processJSONP(\'",string[x 0],"\',",(.j.j x 1),")"};' if @srvType is 'jsonp'
      query += 'if[105=type .h.hp;.h.hp:(f:{ssr[x y;"\nConnection: close";{"\nAccess-Control-Allow-Origin: *\r",x}]})[.h.hp];.h.he:f .h.he;.h.hy:{[a;b;c;d]a[b c;d]}[f;.h.hy]];' if @srvType is "xhttp"
      return @runQuery "{#{query};1}[]", (r,e) => @runQuery q, cb
    @qPrefix = (if @srvType is 'jsonp' then 'jsp?' else "json?enlist ") if !@qPrefix and @rType is "json"
    if @srvType is 'jsonp'
      q = @qPrefix + "(`#{rid = 'id'+Date.now()};#{encodeURIComponent q})"
    else
      q = @qPrefix + encodeURIComponent q
    q = q + "&target=" + trg if @target and trg=extractInfo @target
    q = 'http://' + @wsSrv + '/' + q if @srvType in ['xhttp','jsonp']
    console.log "kdb-srv sending request:"+q if @debug
    return @sendJSONP rid, q, cb if @srvType is 'jsonp'
    xhr = new XMLHttpRequest()
    xhr.onerror = =>
      console.log "kdb-srv error: "+xhr.statusText + " - " + xhr.responseText if @debug
