我想發送登錄數據到網站的api,如果statusCode返回302,那麼我想重定向用戶到另一個網頁。但我的jQuery沒有執行並給我錯誤$ ajax沒有定義。下面是我的jQuery代碼。
$("#asd").click(function(){
alert("sas");
$ajax({
url:'url.com',
type: 'POST',
data: ({
Username: $('#inputUserName').val(),
password: $('#inputPassword').val(),
returnURL: 'url.com',
}),
success : function(data, textStatus,jqXHR)
{
window.location.href="myvideo.html"
},
error :function(jqXHR, textStatus, errorThrown)
{
alert("Invalid username and password");
}
});
});
});
使用像這樣'$ .ajax({'not $ ajax({ –
使用'$ .ajax(...' –
謝謝。 @ ShaunakD – 1binary0