浏览器中模仿跨域请求

 

 

打开浏览器->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("提交失败");
}
});
  

  

 

posted @ 2020-07-22 14:20  zhang_kk  阅读(1053)  评论(0编辑  收藏  举报