[英]jQuery and Ajax - cannot POST
我试图使用已知的用户名和密码登录网站,并从该网站上显示该网站上特定用户帐户的一些数据。 我为此使用jQuery和Ajax。 这是我的代码:
$.ajax({
async: false,
cache: false,
type: 'POST',
dataType: 'json', // json...just for example sake
data: ({
'login_username': username,
'secretkey': password
}),
url: 'https://mail.someserver.com/src/redirect.php',
success: function (data) {
alert("SUCCESS!")
if (data === '1') { // server returns a "1" for success
// success!
// do whatever you need to do
} else {
// fail!
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// something went wrong with the request
alert("Failed!");
}
});
我已经在网络上进行搜索,并且我知道浏览器不允许跨服务器的ajax调用来防止安全问题,但是我已经尝试过使用“ jsonp”作为dataType无效:(
那么,我在做什么错呢?
我的错不是上面的代码,我的错是在清单文件(我正在构建Google Chrome扩展程序)中,我没有设置适当的权限(https:// *)。
对不起,很抱歉!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.