☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How to call complex python function in CustonJS

Community Support
wu.tianchen2015
wu.tianchen2015

I want to use CustionJS callback to trigger a data fetching from cloud database with blaze.

something like:

data fetching function:

def data_fetch():

do something

“on_change” on textInput

callback = CustomJS(args=dict(source=source), code=“”"

var f = cb_obj.get(‘value’)

window.alert(data_fetch(f))

source.trigger(‘change’);

“”")

textInput = TextInput(title=“query_parameters”, name=‘id’, value=‘id’, callback=callback)

I have read this article about How to call python function from javascript: http://stackoverflow.com/questions/13175510/call-python-function-from-javascript-code

I am using dev version 0.11

how can I store the python script on tornado server and call the function through URL in javascript ?

or is there better way to call a complex python function from javascript ?

⌁   Link to post
Bryan
Bryan

Hi,

I'm afraid I am a little unclear on your requirements. You mention a tornado server, are you asking about the new tornado-based Bokeh server? If so, please see some links and info I replied today in the other message "Bokeh-Server Installation on windows (no redis, no conda)" that has much relevance.

If you mean some other tornado server that you just want to make and AJAX call to, that's more of a general JS question, not really specific to Bokeh. CustomJS callbacks let you run whatever JS code you want, so you can certainly make AJAX calls. Some information seems to be here (I cannot vouch for it)

  javascript - How can I make an AJAX call without jQuery? - Stack Overflow

Bryan

···

On Dec 8, 2015, at 9:29 AM, wu.tianchen2015@gmail.com wrote:

I want to use CustionJS callback to trigger a data fetching from cloud database with blaze.

something like:

data fetching function:

    def data_fetch():
        # do something

"on_change" on textInput

    callback = CustomJS(args=dict(source=source), code="""
            var f = cb_obj.get('value')
            window.alert(data_fetch(f))
            source.trigger('change');
        """)
    
       textInput = TextInput(title="query_parameters", name='id', value='id', callback=callback)

I have read this article about How to call python function from javascript: Call Python function from JavaScript code - Stack Overflow

I am using dev version 0.11

how can I store the python script on tornado server and call the function through URL in javascript ?

or is there better way to call a complex python function from javascript ?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d7324fa1-180b-40fd-93c2-19ef496e1946%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled