ajaxを使用してRESTサービスにアクセスしようとしています。
このリンクを任意のWebブラウザーに貼り付けると、次のような結果になります。
{"SessionID":"a7f58a4a-f922-47c1-8351-d2035df4968c","SourceIP":"127.0.0.1","UserID":313}
(セキュリティのためにリンクが変更されました)
https://thisisjustasample/Rest/Authenticate/Login?username = user&password = pass123&ip = 127.0.0.1
しかし、ajaxを使用してリンクにアクセスする運は見つかりませんでした:
「表示」部分からの呼び出し:
getdata('https://thisisjustasample/Rest/Authenticate/Login?username=user&password=pass123&ip=127.0.0.1');
jsファイル内の関数:
function getdata(url) {
$.ajax({
url: url,
type: 'GET',
contentType: 'application/json',
success: function (data) {
if (data) {
showtooltip(data);
}
},
error: function (xhr, ajaxOptions, error) {
showtooltip(xhr.status + ': ' + error);
}
});
}
常に「0」ステータスを返します。また、データベースを確認しても、データに変更はありません。コードの何が問題になっていますか?