jsonp
js:
只有get方式
$.ajax({
type: 'get',
dataType: "jsonp",
jsonp: "callback",
data:{'phone':'12345678901'}
url: 'http://192.168.4.238:8080/api/user/loginCSmsSend',
success: function (data) {
if (data.bstatus.code == 0) {
}
}
});
java:
/**
* 短信发送
*/
@ResponseBody
@RequestMapping(value = ApiUrls.URL_LOGIN_C_SMS_SEND, method = RequestMethod.GET)
public String smsCSend(HttpServletRequest req, HttpServletResponse resp) {
String callback = req.getParameter("callback");
String phone = req.getParameter("phone");
BaseResp bresp = userService.loginSmsSend(phone, new BaseResp());
JsonMapper jm = JsonMapper.buildNonDefaultBinder();
String backStr = callback+"("+jm.toJson(bresp)+");";
return backStr;
}