[英]API call over AJAX
我是AJAX的新手,我想通過此 API生成密碼。 我想使用AJAX,但不確切知道如何以及在何處指定參數。
$.ajax({
url: 'https://passwordwolf.com/?length=10&upper=off&lower=off&special=off&exclude=012345&repeat=5',
dataType: "text json",
type: "POST",
data: {upper: off, lower: on, special: off},
success: function(jsonObject,status) {
console.log("function() ajaxPost : " + status);
}
});
非常感謝,請不要討厭我的編程技能!
看看他們的API:
GET
方法,而不是POST
。 https://passwordwolf.com/api/
(注意末尾的/api
)。 請參閱下面的演示(它在任何地方都使用cors來規避CORS問題)。
它還顯示了如何正確使用對象設置參數 。
var CORS = 'https://cors-anywhere.herokuapp.com/'; $.ajax({ url: CORS + 'https://passwordwolf.com/api/', dataType: "json", type: "GET", data: { length: 10, upper: "off", lower: "off", special: "off", exclude: "012345", repeat: 5 }, success: function(jsonObject, status) { console.log("ajax result: " + JSON.stringify(jsonObject)); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.