django ajax异步加载 实现局部刷新

时间:2025-04-02 08:25:09
<script type="text/javascript" src="${ }/js/jquery-2.1."></script> <script type="text/javascript"> $(function(){ $("#inp1").blur(function(){ var name=$(this).val(); $.ajax({ url:"${}/demo", data:{"uname":name,"upwd":"jack123","age":12}, cache:"false", async:"true", dataType:"json", type:"post", success:function(data){ if(=="1"){ $("#sp").html("用户名存在"); }else{ $("#sp").html(""); } }, error:function(){ alert("服务器端异常"); } }); }); }) </script> <title>Insert title here</title> </head> <body> <input type="text" value="" ><span ></span> </body> </html>