• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
xwlong
博客园    首页    新随笔    联系   管理    订阅  订阅
php输入流简单小例子
<form method="post" action="index.php/home/index/captchaTest">
    <input name="name" id="name" type="text" placeholder="name" />
    <input name="age" id="age" type="text" placeholder="age" />
    <input name="email" id="email" type="text" placeholder="email" />
    <input name="captcha" id="captcha" type="text" placeholder="captcha" />
    <img src="{:captcha_src()}" onclick="this.src='{:captcha_src()}?'+Math.random();" />
    <input name="tijiao" type="button" value="提交" />
</form>
<script type="text/javascript" src="__STATIC__/js/jquery.min.js"></script>
<script type="text/javascript">
    $(':button').click(function(){
        var para = {};
        para['name'] = $('#name').val();
        para['age'] = $('#age').val();
        para['email'] = $('#email').val();
        para['captcha'] = $('#captcha').val();
        $.ajax({
            type: "post",
            url: "{:url('captchaTest')}",
            data: JSON.stringify(para),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(result){
                console.log(result);
            },
            error: function(result){}
        })
    })
</script>
public function captchaTest(){
        $content = file_get_contents("php://input");
        return json_decode($content, true);
}

 

posted on 2017-11-17 14:20  xwlong  阅读(161)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3