problem description
background written by others, I didn"t write the interface before I wrote the interface myself and then called it with ajax to get no data. I don"t know what went wrong. I don"t know exactly where to put the js and html files
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
this is controller
@Controller
@RequestMapping("/some")
public class SomeTestController {
@RequestMapping(value ="/test" )
@ResponseBody
public String getAirportList(HttpServletRequest request) {
JSONObject json = new JSONObject();
json.put("name", "jack");
return json.toJSONString();
}
}
this is ajax
$.ajax({
type:"post",
url:"/some/test",
dataType:"json",
success:function (data) {
alert(data);
},
error:function () {
alert("error");
}
})
what result do you expect? What is the error message actually seen?
then opening the web page will only pop up error