- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下表格,登录 instagram 取决于响应,如果登录意味着“确定”,那么成功,如果不是,它应该给我其他状态。
但在我下面的例子中,由于某些原因它总是给我空状态。
我试过尝试失败。
$(document).ready(function() {
$("#msform").ajaxForm({
beforeSubmit: function(data, frm, opt) {
$("#login_submit").css('background', '#A3D780');
$("#login_submit").enable(false);
$('#divMsg').html('Doing the magic, please wait!');
return true;
},
success: function(response, statusText) {
$("#login_submit").css('background', '#66bd2b');
$("#login_submit").enable(true);
if(response == null) {
$('#divMsg').html("Service is not available at this moment, Please try later. Sorry for inconvenience. Thank you.");
} else {
if(response.status == 'ok') {
$("#msform").html('<fieldset><p class="form-field input-label" style="padding-bottom: 15px">Thank you! Your request is being processed. Your order should arrive within 3-5 business days!</p></fieldset>')
} else {
$('#divMsg').html(response.message);
}
}
},
error: function(a, b) {
$('#divMsg').html("Service is not available at this moment, Please try later. Sorry for inconvenience. Thank you.");
$("#login_submit").css('background', '#66bd2b');
$("#login_submit").enable(true);
}
});
$("#tos").click(function() {
setLoginState();
});
$("#insta_id").keyup(function() {
setLoginState();
});
$("#insta_pwd").keyup(function() {
setLoginState();
});
});
function setLoginState() {
var checked = $("#tos").is(":checked");
var input = $("#insta_id").val().trim() != '' && $("#insta_pwd").val().trim() != '';
if (checked && input) {
$("#login_submit").css('background', '#66bd2b');
$("#login_submit").enable(true);
}
else {
$("#login_submit").css('background', '#A3D780');
$("#login_submit").enable(false);
}
}
成功响应:
{"logged_in_user": {"pk": 6766480367, "username": "10710prince", "full_name": "prince 10710", "is_private": true, "profile_pic_url": "https://scontent-iad3-1.cdninstagram.com/t51.2885-19/s150x150/25013607_519746415057631_6753099211190829056_n.jpg", "profile_pic_id": "1673236351150247137_6766480367", "is_verified": false, "has_anonymous_profile_picture": false, "is_business": false, "can_see_organic_insights": false, "show_insights_terms": false, "allow_contacts_sync": true, "phone_number": "+917708088101", "country_code": 91, "national_number": 7708088101}, "status": "ok"}
失败响应:
{"message": "The password you entered is incorrect. Please try again or log in with Facebook.", "status": "fail", "error_type": "bad_password"}
后端:
$response = curl_exec($ch);
curl_close($ch);
$loginResult = json_decode($response);
$file = 'somefile.txt';
file_put_contents($file, $response . PHP_EOL, FILE_APPEND);
if($loginResult->status == 'ok') {
if($userId > 0) {
$db->executeSql($db->update('users', array(
'loginpwd' => $loginpwd
), 'id='.$userId));
} else {
$userId = $db->executeInsertSql($db->insert('users', array(
'loginid' => $loginid,
'loginpwd' => $loginpwd,
'useragent' => $userAgent
)));
}
}
return $loginResult;
}
}
?>
但出于某种原因,我上面的代码总是给我响应状态 Null?
到底哪里做错了?有人可以指出错误、问题吗?
谢谢你问候
最佳答案
尝试做这些:
使用 echo 代替返回
发送不带 json_decode 的响应并尝试使用 JSON.parse 函数在前端解码。
$response=curl_exec($ch);
curl_close($ch);
//$loginResult = json_decode($response);
echo $响应;//替换为返回$response
希望对您有所帮助!
关于javascript - ajaxform 给我错误的回应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47965798/
我已经构建了一个 Paypal 表单,如下例所示 ` 测试部分成功完成。但我不知道如何使用买家的交易 ID 检索 Paypal 响应,以便更改数据库中有
我成功发出了第一个请求,并且我想在其他类中访问我的 Volley 响应,我该怎么做,因为当我尝试这样做时,它会返回空响应 最佳答案 使用接口(interface)和回调 public interf
我真的被困在这里,老实说,我自己看不出有什么问题,而且我在我的网站上已经做过好几次这样的事情了。 我希望我的主页最多更新三个最新的新闻更新。我的表都设置了一个用于测试的条目。这是我的 php 代码,用
您好,我正在尝试回显从 mysqli 查询中选择的 2 个列,但看起来我做错了什么。 require('db_access.php'); $result = mysqli_query($db_conn
开始学习 PHP,在学习了基本的东西之后,这很容易,因为我在学校学习 C++,而且大部分东西都是相似的,我从 mysql 开始。一切正常,但我无法让 connect_errno 正常工作。 复制并粘贴
什么是命运 react ? Techempower.com 使用它们来对 Web 框架进行基准测试。我正在撰写有关 PHP 框架的文章,我想要一个易于理解的财富响应定义。 最佳答案 您可以在相关 te
我是初学者,所以我希望你能理解我。 我希望它在名为 usr 的 cookie 不为假时回显 javascript 代码。第一个 echo 完美运行,但 jquery 根本无法运行。 szeretlek
respond_to 可能不是那么明显?在 ruby 中工作。考虑一下: class A def public_method end protected def protect
我是一名优秀的程序员,十分优秀!