跨域登陆,注册接口
来源:互联网 发布:软件不兼容是什么意思 编辑:程序博客网 时间:2024/05/21 07:14
/** * 订单接口 */public function orderApi(){ $orderNum=Request::input('id'); $arr=DB::table('order')->where(['orderNUm'=>$orderNum])->first(); echo $_GET['jsoncallback']."(".json_encode($arr).")";die; //print_r($arr);}/** *用户浏览商品接口 */public function goods(){ $id=Request::input('id'); $res=DB::table('goods')->where('u_id',$id)->get(); // print_r($res->u_goods); static $result = array(); foreach ($res as $k => $v) { if (!is_array($v->u_goods)) { $result[$k][] = $v->u_goods; }else{ getRes($v->u_goods); } } echo $_GET['jsoncallback']."(".json_encode($result).")";}
/** *用户注册接口 */
public function register(){
$name=Request::input('name');
$pwd=Request::input('pwd');
$name1=isset($name)?$name:'1';
$pwd1=isset($pwd)?$pwd:'1';
$res=DB::table('user')->insert(['u_name'=>$name1,'u_pwd'=>$pwd1]);
if($res){ echo $_GET['jsoncallback']."(".json_encode(1).")";
}else{ echo $_GET['jsoncallback']."(".json_encode(0).")"; }}/** * 登陆接口 */public function login(){ $name=Request::input('name'); $pwd=Request::input('pwd'); //$name1=isset($name)?$name:'1'; //$pwd1=isset($pwd)?$pwd:'1'; $res=DB::table('user')->where(['u_name'=>$name,'u_pwd'=>$pwd])->first(); if($res){ echo $_GET['jsoncallback']."(".json_encode(1).")"; }else{ echo $_GET['jsoncallback']."(".json_encode(0).")"; }}
调用页面
view层数据<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Document</title> <script type="text/javascript" src="http://localhost/app/public/js/jquery.js"></script></head><body><center> <table> <tr> <td>用户名</td> <td><input type="text" id="name"></td> </tr> <tr> <td>密码</td> <td><input type="password" id="pwd"></td> </tr> <tr> <td><button class="submit">登陆</button></td> <td></td> </tr> </table></center></body></html><script> $('.submit').click(function(){ var name=$('#name').val(); var pwd=$('#pwd').val(); //alert(pwd) $.ajax({ url:"http://www.laravel.cn/index.php/login", type:"GET", dataType:"jsonp", jsonp:"jsoncallback", async:"false", data:{ name:name, pwd:pwd }, success:function(msg){ if(msg==1){ alert("登陆成功") }else{ alert("用户名或密码错误") } } }) })</script>//注册也是同样的请求方式
0 0
- 跨域登陆,注册接口
- 一,注册与登陆接口
- Jmeter接口测试之登陆注册
- App的登陆注册接口安全设计
- 接口回调实现登陆注册界面
- 登陆、注册
- 登陆注册
- 登陆注册
- 登陆注册
- 接口登陆
- 整合SSH--登陆注册
- 登陆、注册小制作
- 项目开发登陆注册
- Zendframework登陆注册实例教程
- webpy注册登陆
- android登陆注册
- APP_注册和登陆
- SSH2注册登陆
- rails 001
- 快速存储Excel格式的代码
- 第八周 顺序串算法
- 互联网协议简介
- 学习游戏要学习编程语言吗?十大主流编程语言解析
- 跨域登陆,注册接口
- AndroidStudio中多个Module依赖同一个jar的解决方案
- 2016 View 使用TextPaint来绘制文字
- 如何使用zipalign工具优化
- DateUtil
- VS错误提示:未处理FileLoadException
- Android弹幕框架 黑暗火焰使
- MFC 与FTP之间的交互
- 学长留的DFS题1-1