Home > front end >  Ajax get json generated in the HTML form
Ajax get json generated in the HTML form

Time:09-27

Class the teacher said to the project to the server, on their computer use apache tomcat - to see the other post, said the project under the apache - tomcat webapps folder, then go to the address bar enter localhost: 8080/... But is not to (the apache tomcat is going in the eclipse open, direct point the startup folder. The bat is not even the cat in the browser interface)


<script SRC="https://bbs.csdn.net/topics/js/jquery-3.1.1.min.js" & gt; </script>
<script>
Window. The onl oad=function () {

$. Ajax ({
Url: "json/student. Json,"
Type: "GET",
DataType: "json",
Success: the function (data) {

$(" # name "). The HTML (data. Name);
$(" # age "). The HTML (data) age);
$(" # birthday "). The HTML (data. Date of birth)
$(" # isLeagueMember "). The HTML (data. Whether the member);
$(" # school "). The HTML () data. The school;
$(" # hobby "). The HTML (data. Hobby);

},
Error: function () {
Alert (" error ");
}

})
}
</script>
Part of HTML



















Name & lt;/td>
Age & lt;/td>
Date of birth & lt;/td>
Whether the party member & lt;/td>
In colleges and universities & lt;/td>
Hobbies & lt;/td>

json part
{
"Name" : "ABC",
"Age" : 20,
"Date of birth" : "2000-1-1",
"Whether member" : true,
"School", "ABC",
"Hobby" : [" basketball ", "cartoon", "travel"]
}

CodePudding user response:

Check your tomcat port is occupied, did not lead to the servers
  •  Tags:  
  • Ajax
  • Related