温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jquery用添加按钮把数据传送给PHP页面

发布时间:2020-05-28 18:05:21 来源:网络 阅读:1319 作者:懒人Z 栏目:web开发

先建一个HTML文件,命名为add.html


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html"  charset="UTF-8" />
<title>添加按钮</title>

     /*要添加好jquery库*/
    <script type="text/javascript" src="jquery-1.7.2.js"></script>
   <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
 
</head>

<body>
<form id="add_form">
  <div>
    <input type="text" name="caizhong"  value="双色球"   id="qg_ssq"/>
    <input type="checkbox" name="qihao" value="20100727" id="qihao" />
  </div>
  <div>
    <input type="submit" name="add_submit" value="添加" id="add_submit" />
  </div>
</form>


   <script type="text/javascript">
  
 $('form#add_form').submit(function() {
      var caizhong=$('input#qg_ssq').val();
   var qihao=$('input#qihao').val();
         alert($(this).serialize());
   $.ajax(
     {
      url: 'add_data.php',
      method: 'get',
      data: $(this).serialize(),
      
      success: function()
      {
       window.open("add_data.php?caizhong="+caizhong+"&qihao="+qihao);
       
       
      }        
     });
         });
  
 </script>


</body>
</html>
 

 


再建一个php页面,命名为:add_data.php


 

<meta http-equiv="Content-Type" content="text/html"  charset="UTF-8" />

<?php
$caizhong=$_GET['caizhong'];
$qihao=$_GET['qihao'];
echo $caizhong;
echo $qihao;
?>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI