zoukankan      html  css  js  c++  java
  • 使用jquery模拟请求,测试项目是否存在跨域限制

    1.Get 请求

    <html>
    	<head><script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script></head>
    	<body>测试Get</body>
    </html>
    <script>
    $(function(){
    	$.ajax({
    	  type: "GET",
    	  url: "http://192.168.9.14:8290/api/admin/user/getMenus",
    	  success: function(msg){
    		 alert( "Data: " + msg );
    	   }
    	});
    })	
    </script>
    

    2.Post 请求

    <html>
    	<head><script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script></head>
    	<body>测试post</body>
    </html>
    
    <script>
    $(function(){
    	 $.ajax({ 
    			type: "POST",
    			url: "http://192.168.9.14:8290/api/admin/login",
    			data: ('{"username":"admin","password":"e10adc3949ba59abbe56e057f20f883e"}'),
    			contentType: "application/json",
    			dataType: "json", 
    			success: function (msg) { 
    			  console.log(msg);
    			}
    	       });
    })
    </script>
    
  • 相关阅读:
    HTML超链接应用场景
    String 字符串和StringBuffer的知识点总结
    猜数游戏代码
    MemoryLayout
    偏swift框架
    git的使用
    寄存器
    swift基础
    枚举
    安装Ubuntu 20.04 以后
  • 原文地址:https://www.cnblogs.com/zhucww/p/10750350.html
Copyright © 2011-2022 走看看