zoukankan      html  css  js  c++  java
  • jquery 跨域访问问题 转

    http://zld406504302.iteye.com/blog/1677937

    服务器,jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%
      String a ="{'name':'tom','sex':'男','age':'24'}";
      String json = request.getParameter("callback");
      json = json +"("+a+")";
      response.getWriter().write(json);
    %>

    js

       <script type="text/javascript">
       $(function(){
           $.ajax({ 
             async:false, 
        url: 'http://localhost:8080/ws/web/pages/data/json.jsp', 
        type: "GET", 
        dataType: 'jsonp', 
        jsonp: 'callback', 
        data: null, 
        success: function (json) {
            alert(json.name);
        }
           });
        })
       </script>
    
    
      
  • 相关阅读:
    数组函数
    跨域
    连接数据库的几种方式
    PHP语言的优缺点
    盗链
    缓存
    电商架构演进
    分布式集群
    序列化
    json
  • 原文地址:https://www.cnblogs.com/kevinge/p/4846075.html
Copyright © 2011-2022 走看看