【问题标题】:Error on AJAX CallAJAX 调用错误
【发布时间】:2013-12-02 12:50:00
【问题描述】:

您好,我正在使用 Spring MVC java 进行项目,当我进行 ajax 调用时,它会出现此错误...我使用 firebug 捕获 -

>>>> Error
"NetworkError: 400 Bad Request -"

这是 POST 请求

HeadersPostResponseHTML
Parametersapplication/x-www-form-urlencoded
teamID  2
Source
teamID=2

说明客户端发送的请求语法错误。

AJAX 调用

<script type="text/javascript" >
function doAjaxPostTeamDelete (){
    //get the values                
    var teamID = $('#teamID').val();         
    $.ajax({
         type: "POST",
         url: "/controller/DeleteTeam",
         data: "teamID=" + teamID,          
         success: function(response){  
             // we have the response                 
         alert("we a  in team delete");                                           
         }, 
         error: function(e){  
         alert('Error: ' + e);  
         }       
    });  
 }   
</script>  

【问题讨论】:

  • 请更新您的问题,提供有关您如何生成 ajax 调用的信息。
  • 服务器端说什么?它是否期望请求中有一个 DELETE 类型?
  • 端点/controller/DeleteTeam是否存在?它能够消费 POST 吗?
  • @RequestMapping(value="/DeleteTeam", method=RequestMethod.POST) public String editDeleteRecodes(@ModelAttribute NewTeams newTeams, BindingResult 结果, @RequestParam String action, Map map){团队团队 = 新团队();团队.setTeamID(newTeams.getTeamID());尝试{ teamService.delete(teams); }catch (DataIntegrityViolationException ex){ map.put("error", "Check the relesse"); System.out.println("aaaaa"); } 返回“重定向:/”; }
  • 这是我的控制器

标签: javascript ajax


【解决方案1】:

HTTP 错误 400 错误请求

客户端(例如您的网络浏览器或我们的 CheckUpDown 机器人)发送的数据流“格式错误”,即不完全遵守 HTTP 协议。因此,Web 服务器无法理解请求并对其进行处理。

http://www.checkupdown.com/status/E400.html

https://support.mozilla.org/en-US/questions/759319

在 Internet 选项中,转到连接选项卡并确保在 LAN 设置窗口中没有检查任何内容,如果没有检查任何内容,请执行 IE 重置(执行重置后,您将丢失保存在个人网站)

【讨论】:

  • 添加了一些解决方案,请尝试一下
猜你喜欢
  • 2014-11-22
  • 2017-02-27
  • 1970-01-01
  • 2017-05-25
  • 2013-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多