我正在一個web應用程序,當我嘗試使用GET方法來撥打電話,儘管網址和重點是正確的,我總是失敗JavaScript的GET方法
的html代碼:
<!DOCTYPE html>
<html>
<head>
<title>cerca</title>
<link rel="stylesheet" href="css/main.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/main.js"></script>
</head>
<br>
<p><img src="img/Bip.png" height="150" width="150"/>
Bip business integration partners
</p>
<h1>Cerca</h1>
<form onsubmit="foundTopic()">
<input name="mioTesto" type="text" id="topicID" placeholder ="Cerca per topic " size="40" maxlength="200" />
<button type="submit" >Cerca</button>
</form><br></br>
<form onsubmit="foundActivities()">
<input name="mioTesto" type="text" id="activitiesID" placeholder="Cerca per activities" size="40" maxlength="200" />
<button type="submit">Cerca</button>
</form><br>
<h5><a href="index.html">home</h5>
</body>
</html>
JS代碼
function foundTopic() {
var topic = document.getElementById("topicID").value;
var url2 = "http://localhost:8080/bip/workTagsTopic/" + encodeURI(topic)
$.ajax({
type: "GET",
url: "http://localhost:8080/bip/workTagsTopic/" + encodeURI(topic),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data, status, jqXHR) {
// do something
console.log("okS")
},
error: function (jqXHR, status) {
console.log(url2)
console.log(topic)
}
});
}
在控制檯它打印這樣的: http://localhost:8080/bip/workTagsTopic/key2 main.js:17個 KEY2 main.js:18
是網址正在擊中? –
是空着,如果我點擊書面鏈接它打開頁面與列表 –
它是與$ .get – Amit