加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

$.ajax的用法

发布时间:2020-12-15 21:43:12 所属栏目:百科 来源:网络整理
导读:!DOCTYPE html html head title我是标题/title /head body form action='./ajax1.php' method="post" id="form" pinput type="test" name="username" id="username"//pspan id="reg"/span pinput type="test" name="password" id="password"//p pinput type=

<!DOCTYPE html>

<html>

<head>

<title>我是标题</title>

</head>

<body>

<form action='./ajax1.php' method="post" id="form">

<p><input type="test" name="username" id="username"/></p><span id="reg"></span>

<p><input type="test" name="password" id="password"/></p>

<p><input type="submit" value="提交"/></p>

</form>

</body>

<script src="./js/jquery-1.7.2.min.js"></script>

<script>



$('#form').submit(function(ev){

var username = $("#username").val();//取框中的用户名

var password = $("#password").val();//取框中的密码


//alert(username);

$.ajax({

type:"post",//以post方式与后台沟通

url : "ajax1.php",//与此php页面沟通

dataType:'text',//从php返回的值以 JSON方式 解释

data: 'username='+username+'&password='+password,

success: function(data){

alert(data);

$('#reg').html(data);

}


});

return false;

});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读