I have an HTML page with one button, and I need to execute a python script when we click on the button and return to the same HTML page with the result.
So I need do some validation on return value and perform some action.
Here is my code:
HTML:
JS:
function validate(){
if (returnvalue=="test") alert(test)
else alert ("unsuccessful")
}
What my python code is doing is some validation on the name entered in the text box and gives the return status.
But I need the result back on the same page, so I can do the form submission later with all the details. Any help will be appreciated
解决方案
You should use Ajax, which is easier with jQuery
$.ajax({
url: "/path/to/your/script",
success: function(response){
//here you do whatever you want with the response variable
}
});
and you should read the jQuery.ajax page since it has too many options.