When I input the input value on the HTML homepage, I want to print the result of using the input value as a variable while executing the py file.

Asked 2 years ago, Updated 2 years ago, 53 views

Situation

ex) Input: 3 -> What is entered in py. Gugudan of the input value (only an example, the actual code is very Kim) -> Output the execution result of py to html (graph or character)

When I searched Google God, there are many examples of using Ajax, but I don't know how to access it from the website I already implemented because it's a format where html starts when I run localhost:5000 or py.

Conclusion: I would like to send a specific input value of html with py and return the execution result of py to html at the same time.

html ajax python py

2022-09-20 22:15

1 Answers

<aid="resultDemander"> What are the results?</a>
<div id="resultContainer"></div>
<!-- Assume that you write roughly jQuery -->
<script>
$('#resultDemander').click(function(e) {
    e.preventDefault();
    $.ajax({
        method: 'GET',
        url: 'http://foobar.com/magic'
        dataType: 'html'
    }).done(function (response) {
        $('#resultContainer').html(response);
    });
});
</script>

Pretend to be fooled and follow along. If there is something you don't understand while doing , please post it as a separate new question.


2022-09-20 22:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.