瀏覽器中模仿跨域請求


 

 

打開瀏覽器->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