Ajax requests are not always successful after they are submitted to the controller

Source: Internet
Author: User

Recently when doing an internship, click on the query in JS to send AJAX requests to the controller backstage, but no matter how unsuccessful, the request address is correct, because in the background with SYSTEM.OUT.PRINTLN output has value, and indeed return, Baidu later found in the SPRINGMVC annotation. You must add the @responsebody annotation to make the AJAX request successful.

Background Part code:

 @RequestMapping ("select.do" ) @ResponseBody  //  add responsebody to return value, Ajax request succeeds    string Selectbydate (HttpServletRequest request, model model) {string B        Egin_date  = Request.getparameter ("begin_date" );        List  <MobileManage> list = Getdatalist (begin_date);        Jsonarray json  = Jsonarray.fromobject (list);        String Pasejson  = Pasejson (list);  //  System.out.println (Json.tostring ()        ); return      Pasejson; }
View Code

Front Section code:

$.ajax ({                       type:"POST",                       URL:"/mylog/mobilemanage/select.do",                       dataType:" JSON ",                       data:{begin_date:begin_date},                       success:function(data) {                                           processing                                     }    })                            
View Code

Ajax requests are not always successful after they are submitted to the controller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.