简体   繁体   English

调用ajax url时HTTP状态404

[英]HTTP status 404 while calling ajax url

I have a form which has submit button and button.我有一个带有提交按钮和按钮的表单。 I am implementing an ajax cal for a button using get method.我正在使用 get 方法为按钮实现 ajax cal。 I have passed value in url.我已经在 url 中传递了值。 and while clicking on button, it is making an ajax cal.在单击按钮时,它正在执行 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".如果我在 mozilla 的“显示命令行弹出窗口”中看到,我可以看到错误状态:404。“请求的资源不可用”。

I am using thymeleaf and spring mvc.我正在使用百里香叶和弹簧 mvc。 below is my ajax cal下面是我的 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 .您可能需要添加@ResponseBody Please also validate the url.还请验证网址。 Also it will be useful if you share the url mapping from application context and web.xml如果您从应用程序上下文和 web.xml 共享 url 映射也会很有用

@RequestMapping(value = "xxx/yyy/searchabc", method = RequestMethod.GET)
    public @ResponseBody String searchabc(Model model){
        log.debug("hello");
         return "helloworld";
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 预检具有无效的 HTTP 状态代码 404 Jquery AJAX POST - Preflight has invalid HTTP status code 404 Jquery AJAX POST Phonegap AJAX URL在Android设备上显示状态404 - Phonegap AJAX URL shows Status 404 on android device HTTP状态404打开HTML页面时请求的资源不可用 - HTTP status 404 the requested resource is not available while opening HTML page XMLHttpRequest具有Blob URL的404状态 - XMLHttpRequest Status of 404 With Blob URL Angular $ http在404上调用成功 - Angular $http calling success on 404 预检的响应具有无效的HTTP状态代码404 - ajax请求浏览器 - Response for preflight has invalid HTTP status code 404 - ajax request browser 如何在调用URL时在HTTP POST请求中发送数据? - How to send data in HTTP POST request while calling a url? XMLHttpRequest无法加载URL响应以进行预检具有无效的HTTP状态代码404 - XMLHttpRequest cannot load url Response for preflight has invalid HTTP status code 404 XMLHttpRequest无法加载URL。 飞行前的响应具有无效的HTTP状态代码404 - XMLHttpRequest cannot load URL. Response for preflight has invalid HTTP status code 404 $ compile:tpload未能加载模板(HTTP状态:404)仅在一个子URL中发生 - $compile:tpload Failed to load template (HTTP status: 404) happens in one sub url only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM