2017-04-21 1 views
0

これは私のpythonコードです。ボタンを使ってHTMLコードページレイアウトに表示したいのですが、javascript 。javascriptコードでpython apiを呼び出したいと思います。私はちょうどhello worldがpythonから呼び出され、javascriptで印刷されていることを確認したいです

print("hello world") (savelist.py) 

そして、これは、ファイル

<html>`<html>` 
<head> 
hjgkhkj 
</head>`enter code here` 
<body> 


<input type="text" name="name" id="name"> 
<button type="button" id="home" onclick="validate()" value="checkvalue"> 
<script> 
$('#id').click(function(){ 

$.ajax({ 
     type:'get', 
     url:<YOUR SERVERSIDE PAGE URL>, 
     cache:false, 
     data:<if any arguments>, 
     async:asynchronous, 
     dataType:json, //if you want json 
     success: function(data) { 
     <put your custom validation here using the response from data structure > 
     }, 
     error: function(request, status, error) { 
     <put your custom code here to handle the call failure> 
     } 
    });enter code here 
}); 
</script> 
</body> 
</html> 

答えて

0

Pythonのファイルは文句を言わない自分自身で何かを送り返すjavascriptの私のhtmlです。あなたはPythonファイル内でAjaxリクエストを処理し、後になった場合はJSON応答を返す方法を提供する必要があります。私はあなたが何を持っているのか探しているのか分からないので、助けてくれるものは何も分からない。

リクエストにリンクしています。docs - >http://docs.python-requests.org/en/master/

関連する問題