script实现Ajax
本教程是判断三角型,而使用的ajax,包括script的一种方式,和jquery的两种方式
-
建立方法(function)
-
代码实例
-
{% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> {%csrf_token%} 三角形A边<input type="text" name="one" id="one" "testajax()"><br> 三角形B边<input type="text" name="two" id="two" "testajax()"><br> 三角形C边<input type="text" name="three" id="three" "testajax()"><br> 通过oninput调用ajax #下面是返回的结果 {% if data%} { {data}} {%endif%} <script> function testajax(){ var one = document.getElementById("one").value; var two = document.getElementById("