码迷,mamicode.com
首页 > Web开发 > 详细

AJAX练习

时间:2016-03-29 12:28:38      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

test.php

<body>
<h1>验证</h1>
<div>代号:<input type="text" id="code" /></div>
<div>品牌:<input type="text" id="name" /></div>
<div><input type="button" value="验证" id="btn"/></div>

</body>
</html>

<script type="text/javascript">
$(document).ready(function(e) {
    
    $("#btn").click(function(){
        
        var code = $("#code").val();
        var name = $("#name").val();
        
        $.ajax({
            
            url:"chuli.php",
            data:{code:code,name:name},
            type:"POST",
            dataType:"text",
            success: function(a){
                
                    alert(a);

                                }
                                  
                              })

        })

});

</script>

chuli.php

<?php

$code = $_POST["code"];

$name = $_POST["name"];

include("mydbda.php");

$db = new mydbda();


$sql = " select count(*) from pinpai where Code= ‘{$code}‘ and Name = ‘{$name}‘";

$str = $db->Select($sql,"CX","mydb");

echo $str;

?>

 

AJAX练习

标签:

原文地址:http://www.cnblogs.com/sihuiming/p/5332268.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!