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君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039
