zoukankan      html  css  js  c++  java
  • jquery利用jsonp 解决跨域问题

    <!DOCTYPE html>
    <html>
    <head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="js/jquery-3.2.1.js"></script>
    </head>
    <body>
    <input type="button" value="获取跨域问题" id="send"/>
    <textarea id="text" style=" 400px; height: 100px;"></textarea>


    <script>
    $(function(){
    $('#btn').click(function(){
    // alert(11)
    $.ajax({
    url:"http://118.184.36.105/p2p/GetScore",
    type:"GET",
    dataType: "jsonp",
    success:function(data){
    var result = JSON.stringify(data);
    console.log(result);
    $("#text").val(result);
    }
    })

    })


    $('#send').click(function(){
    $.ajax({
    url:"http://118.184.36.105/p2p/GetScore",
    dataType:'jsonp',
    success:function(data){
    if(data.status){
    alert(data.msg);
    }
    console.log(data)
    $("#text").val(data);
    }
    })

    })
    })
    </script>
    </body>
    </html>
  • 相关阅读:
    python 模块包裹
    函数指针
    python界面
    python FileError
    python pickle
    python file
    python set
    python 字典的函数
    字典问题
    java学习笔记4
  • 原文地址:https://www.cnblogs.com/yaomengli/p/9203351.html
Copyright © 2011-2022 走看看