Home  >  Q&A  >  body text

javascript - ajax cannot return to the view when entering the background.

ajax jumps to the background and cannot return to the view. What is returned is a whole json array

The methods written before can be used, but I don’t know why it is wrong this time, and the console does not output a new error message.

ajax:

$.ajax({
    type : "post",
        url : "Qtitle/findTypeTitle3",
        dataType : "json",
        data : {"tite" : it},
        success : function(data) {        
            alert(11111); //能弹出
        
        }
});

It stands to reason that it works, data has data, alert() is also triggered, but I don’t know why it still jumps to a page that outputs a json array

世界只因有你世界只因有你2675 days ago600

reply all(5)I'll reply

  • 世界只因有你

    世界只因有你2017-06-23 09:14:24

    The Controller’s method returns JSON data, but @ResponseBody is not added to the method, so the returned JSON data jumps to another page.

    reply
    0
  • ringa_lee

    ringa_lee2017-06-23 09:14:24

    Is the ajax trigger point written on the submit button?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-23 09:14:24

    Clear the project and run it again

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-23 09:14:24

    It is possible that the correct json format is not returned
    The returned data has other code formats

    reply
    0
  • 迷茫

    迷茫2017-06-23 09:14:24

    Have you added the @ResponseBody annotation? This annotation will convert the return value into json format

        //跳转到jsp页面
        @RequestMapping("jspViewTest")
        public String jspViewTest() {
            return "index";
        }
    
        //返回数据对象
        @RequestMapping("dataTest")
        @ResponseBody
        public String dataTest() {
            return "index";
        }

    reply
    0
  • Cancelreply