ajax跨域呼叫和非跨域呼叫的寫法
阿新 • • 發佈:2019-02-12
//支援跨域呼叫 $.ajax({ type:"POST", async :false, url:"http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb&callback=?", dataType:"jsonp", success:function(data){ //alert(data); console.log(data); }, error:function(){ alert("error"); } }); } //不支援跨域呼叫 function b(){ $.ajax({ type: "post", dataType: "html", url: "http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb", data: "", success: function (data) { console.log(data); } }); }