php login json,ajax + php + json = login
2012-05-14 11:47:17
0
I've made a login that uses ajax to send the form to a php file which should return the result..however in a couple of browsers I get errors, while in firefox it seems to work like a charm.
JS:
$.ajax({
type: "POST",
url: "http://www.xxxxxx.net/login.php",
data: dataString,
dataType: "json",
success: function(json) {
if(json.jresult==false){
alert(json.jerror);
}
else{
if(json.identification==0 || json.identification==1){
// register: do some stuff
}
else if(json.identification==2){
// login: do some stuff
}
else{
return(false);
}
}
},
error: function(xhr, textStatus, errorThrown) {
alert('error:'+errorThrown+',status:'+textStatus+',xhr:'+xhr);
},
complete: function(jqXHR, textStatus) {
alert(textStatus);
}
});
Errors I get from the ajax call using Safari,Opera and Rockmelt:
@complete function: textStatus=error
@error function: error:,status:error,xhr: [Object object]
PHP:
session_cache_limiter('nocache');
header('Expires: '.gmdate('r',0));
header('Content-type: application/json');
// set response array
$aDataR = array();
$aDataR['jresult'] = false;
$aDataR['identification'] = -1;
if(!isset($_POST['iID'])){
}
else{
if($_POST['iID']==0){
/* REGISTER */
}
elseif($_POST['iID']==1){
/* LOST PASS */
}
elseif($_POST['iID']==2){
/* LOGIN */
$aDataR['identification'] = 2;
if(false==($mResponse = $cChallenges->CheckLogin($_POST['sUser'],$_POST['sPass']))){
$aDataR['jerror'] = "No such user/password combination";
$cChallenges->ProbeLogin($_POST['sUser'],$_SERVER['REMOTE_ADDR']);
}
else{
$aDataR['jresult'] = true;
$aDataR['jsuccess'] = "Thanks for logging in";
}
}
}
echo htmlspecialchars(json_encode($aDataR), ENT_NOQUOTES);
Left out all code that wasn't important.
Hope anyone can help me out on this one, thanks in advance.
相关知识
json格式
PHP编程实现高效在线订花系统:从需求分析到代码实现详解
基于PHP的花店订购管理系统设计与实现(源码+lw+部署文档+讲解等)
基于php花店订购管理系统设计与实现(源码+lw+部署文档+讲解等)
PHP完整的订单系统订单系统
php动态网站开发 项目教程,PHP动态网站开发项目教程
json 中的ensure
频率与时间换算器
Python爬虫基本流程梳理:构造请求头、发起请求、json格式数据解码转码、读写CSV文件——基于AJAX网页爬虫
纯手打AJAX,还有一个对象转查询字符串的小方法obj=>url
原文链接: php login json,ajax + php + json = login https://www.huajiangbk.com/newsview849531.html
| 上一篇: “可爱经济”掀起文旅新时尚 | 下一篇: 宝贝上下架(淘宝店铺)方案.pp... |
推荐分享

- 1明日花キララ:明日花绮罗年度... 23195
- 2明日花キララ(明日花绮罗)经... 13605
- 3家庭养花知识大全 家庭养花有... 9005
- 4家庭养花风水知识 家庭养花“... 8722
- 5兰花叶子扭的是什么兰 8709
- 6君子兰什么品种最名贵 十大名... 7979
- 7十大致癌花卉排行榜,哪些花卉... 7645
- 8五月天婷婷开心六月丁香:音乐... 7626
- 9秋天养花,掌握这5点养花知识... 7296
- 10【花卉知识 】养花须知:新手... 6897




