[英]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.