       catch err
         console.error "kdb-srv: HTTP callback exception"
         console.log err
-    q = @qPrefix + encodeURIComponent q
-    q = q + "&target=" + trg if @target and trg=extractInfo @target
-    console.log "kdb-srv sending request:"+q if @debug
     xhr.open 'GET', q, true, @srvUser, @srvPass
     xhr.send()
+  sendJSONP: (rid,q,cb) ->
+    resOk = false
+    jsonpRegistry[rid] = (res) =>
+      console.log "kdb-srv(jsonp) data: " + res.toString().slice(0,50) if @debug
+      delete jsonpRegistry[rid]
+      resOk = true
+      try
+        cb res, null
+      catch error
+        console.error "kdb-srv: HTTP callback exception"
+        console.log error
+    script = document.createElement('script')
+    script.onload = script.onerror = =>
+      return if resOk
+      delete jsonpRegistry[rid]
+      console.log "kdb-srv(jsonp): error" if @debug
+      try
+        cb null, "url: "+q
+      catch error
+        console.error "kdb-srv: HTTP callback exception"
+        console.log error
+    script.src = q
+    document.body.appendChild script
 
 class _KDBQuery extends HTMLElement
   createdCallback: ->

    @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

        @kEditor.navigateFileEnd()
        @kEditor.navigateLineEnd()
        @kEditor.insert r
      @kEditor.navigateTo 0,0
    if cfg
      if cfg.row?
        @kEditor.scrollToLine (cfg.row or 0), true, true, null
        @kEditor.navigateTo (cfg.row or 0),(cfg.column or 0)
      if cfg.markers?
        (@kEditor.getSession().removeMarker m for m in @kMarkers) if @kMarkers
        Range = ace.require('./range').Range
