jsonp代码格式转换

来源:互联网 发布:js 字符串转时间戳 编辑:程序博客网 时间:2024/06/09 00:46
@RequestMapping(value="/pagealltype",method={RequestMethod.GET,RequestMethod.POST})
public   void  pagealltype(HttpServletRequest  request,HttpServletResponse  response) throws IOException{
  String callback =request.getParameter("callback");     
   JSONObject   list=feijiebudu_booktypeinter.pagealltype(); 
       
       String retStr =callback + "(" + list + ")";  //解决问题方法  
       response.setCharacterEncoding("UTF-8"); 
       response.getWriter().print(retStr);
//String messageContent = new String(request.getParameter("messageContent").getBytes("iso-8859-1"),"utf-8");




}



$(function() {
$(".swiper-container3").click(function() {
console.log("我点击了图书");
});
$(".swiper-container2 .title").click(function() {
console.log($(this).html());
});
$.ajax({
type: "post",
url: "http://192.168.1.250:8080/controller/pagehome/pagealltype",
dataType: "jsonp",
jsonp: "callback",
      scriptCharset: 'utf-8',  
success: function(data) {
console.log(data.rows);
console.log("请求成功");
$.each(eval(data.rows),function(i,text){
console.log(text.booktypeName);
})
}
});
})

 

 可以访问这个博客查看详解     http://blog.csdn.net/maoxiao1229/article/details/7255441?locationNum=1&fps=1

0 0
原创粉丝点击