Sir
How to retrieve json data using javascript using web API Url in asp.net
I have an issue with below code. Result not showing in json format when clicking "Submit Button" which calls java Fuction
Example Doc no : 900, 484, 923, 865
Please advice me
Thank you
Maideem
Below is my code
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Receipt No"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<div>
<asp:Button ID="BtnSubmit" runat="server" Text="Submit" OnClientClick="GetDetails()" />
</div>
<script type="text/javascript">
function GetDetails(varCnNo) {
var varCnNo = document.getElementById('<%= TextBox1.ClientId %>').value;
alert(varCnNo);
return true;
const url = new URL("http://courier.silsnetwork.com/WebService.asmx/GetBizTrak_DOCNO?strDocNo=" & varCnNo);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json"
};
let body = {
"docno": varCnNo //
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
}
</script>