cross-domain issues
PC-side for security, so cross-domain is prohibited. When I use MUI as a mobile web, I will inevitably use my PC browser for debugging. Mui.ajax is allowed across domains. In order to be able to debug successfully, the browser needs to be set and. For example, the 360 haste browser is set up as follows:
Add--disable-web-security (preceded by a space) after the target
front-end settings
<script type= "Text/javascript" charset= "UTF-8" > reginfo = {name: ' Wuchao ', Password: ' 000111 '}; Mui.ajax (' http://localhost:8080/share/mobile/regist.do ', {data:JSON.stringify (Reginfo), DataType: ' JSON ',// The server returns JSON format data contenttype: "Application/json", type: ' Post ',//http request type timeout:10000,//timeout set to 10 seconds; headers:{' Content-type ': ' Application/json '}, success:function (data) {//server returns a response, based on the response result, analyzes whether the login succeeded; alert (Data.result);}, Error:function (Xhr,type,errorthrown) {//exception handling; alert ("error");},headers: {' access-control-allow-headers ': ' X-requested-with '}});</script>
back-end settings
Requires three jar packages, Jackson-annotations-2.7.0.jar Jackson-core-2.7.0.jar Jackson-databind-2.4.5.jar (version is selected as 2.4.5 should be available, but DataBind package selected as 2.7.0 will error) click here.
The controller is as follows:
@RequestMapping (value = "/mobile/regist", method=requestmethod.post,produces = "Application/json;charset=utf-8") Public @ResponseBody Modelandview Handle4mobile (@RequestBody info info) {System.out.println (Info.getname ()); map<string, string> map = new hashmap<string, string> (); Map.put ("Result", "sucess"); return new Modelandview (New Mappingjackson2jsonview (), map);}
where the info class corresponds to the front-end incoming JSON data. The data returned corresponds to the callback function of the front-end success.
Mui.ajax and Server (SPRINGMVC) transfer JSON data