浏览器中模仿跨域请求


 

 

打开浏览器->f12->console,最好是http开头的

#引入jq

var jquery = document.createElement('script');
undefined
jquery.src = 'http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js';
"http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"
document.getElementsByTagName('head')[0].appendChild(jquery);

 

$.ajax({
url:"http://127.0.0.1:7101/file/adminFileList",//发送的路径
type:"get",//发送的方式
// data:'{"newsId":"5","type":"1","operation":"1"}',//发送的数据
contentType: "application/json", //提交数据类型
dataType:"json",//服务器返回的数据类型
success: function(data) {
if(data.msg="success"){
alert("已提交成功");

}else{
alert("提交失败");
}
},
error: function (data){
alert("提交失败");
}
});
  

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM