I have a form which has submit button and button. I am implementing an ajax cal for a button using get method. I have passed value in url. and while clicking on button, it is making an ajax cal. but in the middle before success function, stopping abruptly. If I see in "Show Command Line Popup" in mozilla, I am able to see the error status:404."The requested resource is not available".
I am using thymeleaf and spring mvc. below is my ajax cal
<script type="text/javascript">
function process(){
alert("button clicked");
$.ajax({
url:'searchabc',
}).done(function (){
alert("success");
});
}
</script
and spring method:
@RequestMapping(value = "xxx/yyy/searchabc", method = RequestMethod.GET)
public String searchabc(Model model){
log.debug("hello");
return "helloworld";
}
Just change:
url:'./searchabc',
To:
url:'searchabc',
You may need to add @ResponseBody
. Please also validate the url. Also it will be useful if you share the url mapping from application context and web.xml
@RequestMapping(value = "xxx/yyy/searchabc", method = RequestMethod.GET)
public @ResponseBody String searchabc(Model model){
log.debug("hello");
return "helloworld";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.