javascript - ajax cannot return to the view when entering the background.
世界只因有你
世界只因有你 2017-06-23 09:12:24
0
5
638

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

世界只因有你
世界只因有你

reply all(5)
世界只因有你

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

ringa_lee

Is the ajax trigger point written on the submit button?

伊谢尔伦

Clear the project and run it again

曾经蜡笔没有小新

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

迷茫

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";
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template