Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

call python function from javascript

All you need is to make an ajax request to your pythoncode. You can do this with jquery http://api.jquery.com/jQuery.ajax/, or use just javascript

$.ajax({
  type: "POST",
  url: "~/pythoncode.py",
  data: { param: text}
}).done(function( o ) {
   // do something
});
Comment

call javascript function from python

You need to install js2py or requests-html packages to run the JavaScript program from Python

//example :
//javaScript function : squareofNum()
code in python : 
import js2py

squareofNum = "function f(x) {return x*x;}"

result = js2py.eval_js(squareofNum)

print(result(5))
>>output : 25
Comment

PREVIOUS NEXT
Code Example
Javascript :: select 2 select trigger 
Javascript :: check all checkboxes on table 
Javascript :: moment time from now 
Javascript :: kubernetes taint master node 
Javascript :: using arrow function and destructuring 
Javascript :: how to show multiple image preview in jquery 
Javascript :: javascript typeof 
Javascript :: how to use for of in javascript 
Javascript :: declaring constant in jsx 
Javascript :: sort JavaScript array by two numeric fields 
Javascript :: sum range javascript 
Javascript :: js catch all images errors 
Javascript :: js array split by comma 
Javascript :: js detect user mobile 
Javascript :: add an object to an array mongosse 
Javascript :: how to get css property of div after rendering in react js 
Javascript :: videojs 100%width 
Javascript :: jquery function done 
Javascript :: string substring last 3 and first character 
Javascript :: what is undefined 
Javascript :: clear timeout in function js 
Javascript :: filter array inside array of objects javascript 
Javascript :: what is the difference between console.log and return 
Javascript :: array from string js 
Javascript :: mongoose get id after save 
Javascript :: cookies in react native 
Javascript :: forever.js 
Javascript :: how to write a variable in js 
Javascript :: does pycharm support javascript 
Javascript :: ckeditor config 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =